Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Load the xml string into an <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx" rel="nofollow">XmlDocument</a> and extract the values with <a href="http://www.w3.org/TR/xpath/" rel="nofollow">XPath</a>:</p> <pre><code>Dim doc = new XmlDocument() doc.LoadXml(yourXmlString) Dim nsm = new XmlNamespaceManager(doc.NameTable) nsm.AddNamespace("a", "http://site.co.uk/") txtStreet.Text = doc.SelectSingleNode("/a:Address/a:strStreet", nsm).InnerText </code></pre> <p>Here's a working snippet:</p> <pre><code>Dim doc = New XmlDocument() doc.LoadXml("&lt;Address xmlns:xsd=""http://www.w3.org/2001/XMLSchema"" xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns=""http://site.co.uk/""&gt;&lt;strOrganisation /&gt; &lt;strProperty /&gt; &lt;strStreet&gt;Some Road&lt;/strStreet&gt; &lt;strLocality /&gt; &lt;strTown&gt;City&lt;/strTown&gt; &lt;strCounty /&gt; &lt;strPostcode&gt;LU1 5QG&lt;/strPostcode&gt;&lt;strDPS /&gt;&lt;/Address&gt;") Dim nsm = New XmlNamespaceManager(doc.NameTable) nsm.AddNamespace("a", "http://site.co.uk/") Dim streetValue = doc.SelectSingleNode("/a:Address/a:strStreet", nsm).InnerText </code></pre> <p>Some things to note:</p> <ol> <li>For XPath lookups, if your xml has a namespace you'll need to add it to an <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlnamespacemanager.aspx" rel="nofollow">XmlNameSpaceManager</a> created from your <a href="http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.nametable.aspx" rel="nofollow">XmlDocument's NameTable</a>.</li> <li>If you don't want to bother with that, you can walk the node collections manually via <code>doc.ChildNodes[0].ChildNodes[0]</code> etc.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload