XML Looping

Vickster

Vickster
Local time
Today, 15:19
Joined
Aug 10, 2010
Messages
1
I am trying to parse an XML document. I have run into a problem looping. The structure of the document is as follows:
header data
hd-el1
hd-el2
DateTime
dt-el1
dt-el2
Reference
rf-el1
rf-el2
Address
ad-el1
ad-el2
ad-el3
Approp
ap-el1
ap-el2
Accounting
ac-el1
ac-el2

I can have up to 1800 header data transactions per file and each of the sub nodes can have multiple iterations.
My code is as follows:
Public Sub Main()
reader = New XmlTextReader(filename)

outfile = "my_test_file.xml"
FileOpen(2, outfile, OpenMode.Append)

Dim x As Integer

outline = " "
PrintLine(2, outline)
outline = "I'm going to do the test_read_to_desc"
PrintLine(2, outline)
reader.MoveToContent()
reader.ReadToDescendant("DateTime")
test_read_to_desc()
outline = "I'm back "
PrintLine(2, outline)
End Sub
Public Sub test_read_to_desc()
Dim z As Integer
' Using reader As XmlReader = XmlReader.Create(filename)


Do
PrintLine(2, outline)
reader.ReadToFollowing("DTA")
reader.Read()
outline = "DTA = " & reader.Name & " or " & reader.Value
PrintLine(2, outline)
reader.ReadToFollowing("DTB")
reader.Read()
outline = "DTB = " & reader.Name & " or " & reader.Value
PrintLine(2, outline)
reader.ReadEndElement()
Loop While reader.Read(??????)

End Sub

I have not been able to figure out how to stop the LOOP. The above code gives me all the date information for the entire file, not just for the corresponding header. What do I need to do to stop this loop.

Any help is welcomed.

Thanks in advance,

Vickster :confused:
 

Users who are viewing this thread

Back
Top Bottom