Hello,
I have an xml document similar to the what's below. I'm wondering how I can read the document and all of its child nodes. I want to only read the parent node called MYTYPES and disregard MYGRAPH. The code I am using reads the document but only prints out the parent node (Type1 and Type 2, in this example). How do i get all the child nodes, and their children. For example, i would like to print out:
Type 1: Clarion, 10. Pittsburgh, 20
Type 2: Trention, 10. Harrisburgh, 20
Code:Try
Dim ds As New DataSet
ds.ReadXml(xmlFilePath & "myFile.xml")
For Each r As DataRow In ds.Tables(0).Rows
Debug.Print(r.Item(0).ToString)
Next
Catch ex As Exception
Throw
End Try
Code:<?xml version="1.0" standalone="yes"?>
<MYPARENT>
<MYTYPES>
<MYTYPE>Type 1</MYTYPE>
<MYLOCATIONS>
<LocationName>Clarion</LocationName>
<Age>10</Age>
</MYLOCATIONS>
<MYLOCATIONS>
<LocationName>Pittsburgh</LocationName>
<Age>20</Age>
</MYLOCATIONS>
</MYTYPES>
<MYTYPES>
<MYTYPE>Type 2</MYTYPE>
<MYLOCATIONS>
<LocationName>Trenton</LocationName>
<Age>10</Age>
</MYLOCATIONS>
<MYLOCATIONS>
<LocationName>Harisburgh</LocationName>
<Age>20</Age>
</MYLOCATIONS>
</MYTYPES>
<MYGRAPH>
<GRAPHNAME>NAME1</GRAPHNAME>
<TOTAL>1</TOTAL>
</MYGRAPH>
<MYGRAPH>
<GRAPHNAME>NAME2</GRAPHNAME>
<TOTAL>2</TOTAL>
</MYGRAPH>
</MYPARENT>
