Difficulty of reading specific xml file

PrivateSub

New member
Joined
Jun 25, 2007
Messages
2
Programming Experience
3-5
Hi everyone,

I am facing a little problem with getting the right data out of the data.xml file that i've uploaded. All i am doing is setting a new dataset in vb.net
and then executing the dataset.ReadXml("...") command.

All i want is to get some of the lower values inside the "rec" node of the xml file such as

FOR EACH DEV ID (1,2,3) I WANT TO TAKE THE FOLLOWING VALUES

"wr_e_day"
"wr_uac_l3"
"wr_udc"

When i 'm checking the whole dataset, i can't seem to find this values. Can anyone help me please, its very urgent.

Thanks in advance!
 

Attachments

  • data.zip
    652 bytes · Views: 22
They will be located in the dev DataTable. Since you have 2 different dev tags (<devs><dev> & <rec)<dev> you'll need to check if the row has values in the fields you're looking for.

VB.NET:
		Dim ds As New DataSet
		ds.ReadXml("C:\Temp\data.xml")

		For Each row As DataRow In ds.Tables("dev").Rows
			If row.Item("wr_e_day").ToString <> "" Then
				MessageBox.Show(String.Format("wr_e_day: {0}{1}wr_uac_l3: {2}{1}wr_udc: {3}", _
				 row.Item("wr_e_day").ToString, _
				 Environment.NewLine, _
				 row.Item("wr_uac_l3").ToString, _
				 row.Item("wr_udc")))
			End If
		Next
 
They are in the "dev" table in the dataset, first 3 rows is the dev nodes of devs node, last 3 rows is the dev nodes of t_vals/rec node.

Here's how to read this as xml document and query with xpath:
VB.NET:
Dim doc As New Xml.XmlDocument
doc.Load("filepath")
For Each dev As Xml.XmlNode In doc.SelectNodes("//rec/dev")
    Dim wr_e_day As String = dev.Attributes("wr_e_day").Value

Next
 
Back
Top