Hi,
I have a XML file:
<?xml version="1.0" encoding="ISO-8859-1"?>
<Report>
<config repstarttime="" rependtime=""></config>
<cashdrops></cashdrops>
<cashsheets></cashsheets>
<cspdata></cspdata>
<fdremdata>
<fdrementry ENTRYID=""></fdrementry>
</fdremdata>
<SHIFTDATA>
<SHIFT_CD_Index ShiftSystemIndex="1" Shift_CD_Used="1" ></SHIFT_CD_Index>
<SHIFT_CD_Index ShiftSystemIndex="2" Shift_CD_Used="1" ></SHIFT_CD_Index>
<SHIFT_CD_Index ShiftSystemIndex="3" Shift_CD_Used="1" ></SHIFT_CD_Index>
<SHIFT_CD_Index ShiftSystemIndex="4" Shift_CD_Used="1" ></SHIFT_CD_Index>
</SHIFTDATA>
<Order>
<OrderHead filelocation="" filesuccess="TRUE" Attendant=""></OrderHead>
<NFC1DATA nfc1count="0"></NFC1DATA>
<PAYMENTDATA paymentcount="1">
<payentrydata id="1"></payentrydata>
</PAYMENTDATA>
<CASHBACKDATA cashbackcount="0"></CASHBACKDATA>
<Product>
<productdata ProdCompActive="FALSE" ProdDesc="Product1" ProdIDNum="00001" ProdQty="1">
<productsession>
<productsessiondata>[CONTENT1] *1;</productsessiondata>
<productsessiondata>[CONTENT2] *1;</productsessiondata>
<productsessiondata>[CONTENT3] *1;</productsessiondata>
<productsessiondata>[CONTENT4] *1;</productsessiondata>
<productsessiondata>[CONTENT5] *4;</productsessiondata>
<productsessiondata>[CONTENT6] *4;</productsessiondata>
</productsession>
</productdata>
</Product>
<histdata id="1" SYS_ID="1" DTE="20120401"></histdata>
<histdata id="2" SYS_ID="1" DTE="20120401"></histdata>
<histdata id="3" SYS_ID="0" DTE="20120401"></histdata>
<histdata id="4" SYS_ID="1" DTE="20120401"></histdata>
<histdata id="5" SYS_ID="0" DTE="20120401"></histdata>
<FooterDATA footercount="0"></FooterDATA>
</Order>
</Report>
and I need to read PRODUCT informations.
The script that I made reads details from "productdata" and only first line from "productsessiondata". Could you advise how I can read all "productsessiondata" details, please?
Here is the code in vb 2008:
Imports System.Xml
Imports System.Xml.Serialization
Imports System.IO
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim file As String = "c:\db\test.xml"
Dim doc As XDocument = XDocument.Load(file)
For Each product As XElement In doc.Descendants("productdata")
MessageBox.Show("ID : " + product.Attribute("ProdDesc").Value)
Next
For Each product As XElement In doc.Descendants("productsession")
If product.HasElements Then
MessageBox.Show("ID : " + product.Element("productsessiondata").Value)
End If
Next
End Sub
End Class