Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27349

VS 2010 Read xml

$
0
0
Hi all.

I read a xml file and want to "extract" some data.

Xml file:

<matrix name="">
<column quantity="SN.Device">
<t-s i="1" value="S2000867174000020" />
</column>
<column quantity="Name.Group">
<t-s i="1" value="DIRECT" />
</column>
</matrix>

I use this code:
Code:

'Load the XML file.
        Dim xml_doc As New Xml.XmlDocument
        xml_doc.Load("my.xml")

        ' Get the desired children.
        Dim child_nodes As XmlNodeList = _
          xml_doc.GetElementsByTagName("column")


        ' Process the children.
        Dim txt As String = ""
        For Each child As XmlNode In child_nodes
            txt &= _
                child.Attributes("quantity").InnerXml & " = " & _
                child.InnerText & vbCrLf
        Next child

        RichTextBox2.Text = txt

The output is:
SN.Device =
Name.Group =

However I want the output to be:


SN.Device = S2000867174000020
Name.Group = DIRECT


I use the InnerText, and obvious there is nothing inside >< but how should I do this?

Viewing all articles
Browse latest Browse all 27349

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>