XML in Visual Basic reading multiple lines



So I am trying to work with a XML file and reading lines from it. An extract of it is here:


<Door Id="pce.car01-L1" In="0" Out="0" Err="0" /> <Door Id="pce.car01-R1" In="0" Out="0" Err="1" /> <Door Id="pce.car01-L2" In="0" Out="0" Err="0" />


I currently have the code below:



Dim doc As New XmlDocument

Dim root As XmlNode = doc.DocumentElement

Dim stopdata As XmlNode = root.SelectSingleNode("/Header/Stop")
Dim doordata(6) As XmlNode
doordata(1) = root.SelectSingleNode("/Header/Stop/Doors/Door")

Stopnumber = stopdata.Attributes.ItemOf("Id").InnerText


stops(0) = stopdata.Attributes.ItemOf("Id").InnerText
stops(1) = stopdata.Attributes.ItemOf("ArrivalT").InnerText
stops(2) = stopdata.Attributes.ItemOf("DepartureT").InnerText
doors(0, 0) = doordata(1).Attributes.ItemOf("Id").InnerText
doors(1, 0) = doordata(1).Attributes.ItemOf("In").InnerText
doors(2, 0) = doordata(1).Attributes.ItemOf("Out").InnerText
doors(3, 0) = doordata(1).Attributes.ItemOf("Err").InnerText


this is only a part of the big file of code.this code saves the data in ID = pce.car01-L1. I need it to read the data for pce.car01-R1 and save it in the array's next column. Can you please help me as to how to get it to read the next attribute of a XML file too?


Regards


No comments:

Post a Comment