troubleshooting Question

Get xml data

Avatar of JJKing
JJKingFlag for United Kingdom of Great Britain and Northern Ireland asked on
Web Languages and StandardsVisual Basic ClassicXML
2 Comments1 Solution735 ViewsLast Modified:
Hi

I have the following xml document and I want to retrieve the <env:identity> value. I am using VB.Net and have code to try and extract the data but I cannot seem to get it to work.

Any Ideas ?

<Envelope xmlns="http://www.intentia.com/MBM" xmlns:env="http://www.intentia.com/MBM_Envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:schemaLocation="http://www.intentia.com/MBM Prototype_Order.xsd">
      <Header>
            <env:delivery>
                  <env:to>
                        <env:address>Movex</env:address>
                  </env:to>
                  <env:from>
                        <env:address>Eprocurement</env:address>
                  </env:from>
                  <env:reliability>
                        <env:sendReceiptTo>
                        </env:sendReceiptTo>
                        <env:receiptRequiredBy>
                        </env:receiptRequiredBy>
                  </env:reliability>
            </env:delivery>
            <env:properties>
                  <env:identity>100QDP
                  </env:identity>
                  <env:sentAt></env:sentAt>
                  <env:expiresAt>
                  </env:expiresAt>
                  <env:topic></env:topic>
            </env:properties>
            <env:manifest>
                  <env:reference uri="#BasdaOrder@1">
                        <env:description></env:description>
                  </env:reference>
            </env:manifest>
            <env:process>
                  <env:type>0</env:type>
                  <env:instance>
                  </env:instance>
                  <env:handle>
                  </env:handle>
            </env:process>
      </Header>
      <Body>
    <Order xmlns="urn:schemas-basda-org:2000:purchaseOrder:xdr:3.01" xmlns:xdr="XDR-compat-v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:schemas-basda-org:2000:purchaseOrder:xdr:3.01 Order-v3.xsd">
</Order>
</Body>
</Envelope>
Public Function RetrieveXMLNodeData() As String
        Try
            RetrieveXMLNodeData = Nothing
            Dim doc As New XmlDocument
            doc.Load(MyDocPath)
            Dim root As XmlElement = doc.DocumentElement
            Dim Nmspc = New XmlNamespaceManager(doc.NameTable)
            Nmspc.AddNamespace("A", "env:http://www.intentia.com/MBM_Envelope")
            RetrieveXMLNodeData = root.SelectSingleNode("A:properties/A:identity",  nmspc).InnerText
Catch ex As Exception
            Throw ex
        End Try
    End Function
ASKER CERTIFIED SOLUTION
Dimitris
Senior Solution Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros