I have an XML file in which I would like to retrieve all unique paths from. In the following example:
<?xml version="1.0" encoding="utf-8"?>
<views>
<invoice>
<newRa elem="0">
<createD>20150514</createD>
<modD>1234</modD>
<sample>text</sample>
</newRa>
<total>1.99</total>
</invoice>
</views>
I want to retrieve:
views/invoice/newRa/createD
views/invoice/newRa/modD
views/invoice/newRa/sample
and so on......
I have some experience with xPath, but I'm not sure how to begin in VB setting up a sub that will do this for me. Mind you I'm working with .NET 2.0 so LINQ is not possible.
EDIT 1:
Dim xOne As New XmlDocument
xOne.Load("d/input/oneTest.xml")
For Each rNode As XmlNode In xOne.SelectSingleNode("/")
If rNode.HasChildNodes Then
subHasChild(rNode)
End If
Next
Private Sub subHasChild(ByVal cNode As XmlNode)
Dim sNode = cNode.Name
If cNode.HasChildNodes Then
sNode = sNode + "/" + cNode.FirstChild.Name
cNode = cNode.FirstChild
subHasChild(cNode)
End If
Dim sw As New StreamWriter("d:\input\paths.txt")
sw.WriteLine(sNode)
sw.Flush() : sw.Close() : sw.Dispose()
End Sub