Results 1 to 2 of 2

Thread: [RESOLVED] xmldocument help reading data from xml

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Minnesota
    Posts
    830

    [RESOLVED] xmldocument help reading data from xml

    I can't seem to loop through my xml results. Here is what I have so far. I did testing by replacing the namespace (xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://domain.com/folder") from the xml and can get to work but not when it's included.

    It's something with how I am using the xmlnamespacemanager.

    Code:
    Private Sub btn2kImages_Click(sender As System.Object, e As System.EventArgs) Handles btn2kImages.Click
            Dim xdoc As XmlDocument = New XmlDocument
            xdoc.LoadXml(txtXml.Text)
            Dim nsMgr As XmlNamespaceManager = New XmlNamespaceManager(xdoc.NameTable)
            nsMgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")
            nsMgr.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema")
            nsMgr.AddNamespace("ns", "http://domain.com/folder")
    
            Dim xNodesList = xdoc.SelectNodes("/ArrayOfAsfSku/asfSku/SkuVal", nsMgr)
    
            Dim sTemp As String = ""
            For Each xChildNode As XmlNode In xNodesList
                If Not (xChildNode Is Nothing) Then
                    sTemp &= xChildNode.InnerText & ","
                End If
            Next
            MessageBox.Show(sTemp)
        End Sub
    Data
    HTML Code:
    <?xml version="1.0" encoding="utf-8"?>
    <ArrayOfAsfSku xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://domain.com/folder">
      <asfSku>
        <SkuVal>AA0625-PEA</SkuVal>
      </asfSku>
      <asfSku>
        <SkuVal>AA2800-NA</SkuVal>
      </asfSku>
      <asfSku>
        <SkuVal>AA2803-NA</SkuVal>
      </asfSku>
      <asfSku>
        <SkuVal>AA2813-NA</SkuVal>
      </asfSku>
      <asfSku>
        <SkuVal>AA2815-NA</SkuVal>
      </asfSku>
      <asfSku>
        <SkuVal>AA4268-IN</SkuVal>
      </asfSku>
      <asfSku>
        <SkuVal>AA4270-IN</SkuVal>
      </asfSku>
      <asfSku>
        <SkuVal>AA4272-IN</SkuVal>
      </asfSku>
    </ArrayOfAsfSku>
    Last edited by lleemon; May 13th, 2013 at 05:32 PM. Reason: resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width