Hallo zusammen,
ich habe eine XML Datei, die ich einlesen möchte.
Ich bekomme das hin das sich alle werte von "<SalesGroupStatement>" einlese.
Ich benötige aber dazu auch die Information "<DailyStatement Number="XXXX">"
und die "Station No" zu jeder "<SalesGroupStatement>" Datensatz.
So wie ich es mache, liest er nur den ersten Datensatz aus.
Hat jemand ein Tipp für mich?
ich habe eine XML Datei, die ich einlesen möchte.
Ich bekomme das hin das sich alle werte von "<SalesGroupStatement>" einlese.
Ich benötige aber dazu auch die Information "<DailyStatement Number="XXXX">"
und die "Station No" zu jeder "<SalesGroupStatement>" Datensatz.
So wie ich es mache, liest er nur den ersten Datensatz aus.
Hat jemand ein Tipp für mich?
XML-Quellcode
- <?xml version="1.0" encoding="ISO-8859-1"?>
- <Root>
- <Received>
- <StationNo>102</StationNo>
- <ReceivedTimestamp>2021-08-16T08:40:08+02:00</ReceivedTimestamp>
- </Received>
- <DailyStatement Number="3559">
- <Timestamp>2021-08-15T23:55:00+02:00</Timestamp>
- <SalesGroupStatement CommodityGroupNumber="69" ServiceType="1">
- <Timestamp>2021-08-15T05:00:00+02:00</Timestamp>
- <UnitPrice>0,749</UnitPrice>
- <UnitPriceNew>0,749</UnitPriceNew>
- <FinalAmount>0,00</FinalAmount>
- <FinalQuantity>0,00</FinalQuantity>
- <ForecourtType>H</ForecourtType>
- </SalesGroupStatement>
- <SalesGroupStatement CommodityGroupNumber="96" ServiceType="8">
- <Timestamp>2021-08-15T05:00:00+02:00</Timestamp>
- <UnitPrice>1,800</UnitPrice>
- <UnitPriceNew>1,800</UnitPriceNew>
- <FinalAmount>0,00</FinalAmount>
- <FinalQuantity>0,00</FinalQuantity>
- <ForecourtType>H</ForecourtType>
- </SalesGroupStatement>
- </DailyStatement>
- <DailyStatement Number="3560">
- <Timestamp>2021-08-15T23:55:00+02:00</Timestamp>
- <SalesGroupStatement CommodityGroupNumber="69" ServiceType="1">
- <Timestamp>2021-08-15T05:00:00+02:00</Timestamp>
- <UnitPrice>0,749</UnitPrice>
- <UnitPriceNew>0,749</UnitPriceNew>
- <FinalAmount>0,00</FinalAmount>
- <FinalQuantity>0,00</FinalQuantity>
- <ForecourtType>H</ForecourtType>
- </SalesGroupStatement>
- <SalesGroupStatement CommodityGroupNumber="97" ServiceType="1">
- <Timestamp>2021-08-15T05:00:00+02:00</Timestamp>
- <UnitPrice>0,499</UnitPrice>
- <UnitPriceNew>0,499</UnitPriceNew>
- <FinalAmount>0,00</FinalAmount>
- <FinalQuantity>0,00</FinalQuantity>
- <ForecourtType>H</ForecourtType>
- </SalesGroupStatement>
- <SalesGroupStatement CommodityGroupNumber="69" ServiceType="8">
- <Timestamp>2021-08-15T05:00:00+02:00</Timestamp>
- <UnitPrice>0,749</UnitPrice>
- <UnitPriceNew>0,749</UnitPriceNew>
- <FinalAmount>0,00</FinalAmount>
- <FinalQuantity>0,00</FinalQuantity>
- <ForecourtType>H</ForecourtType>
- </SalesGroupStatement>
- </DailyStatement>
- </Root>
VB.NET-Quellcode
- Dim doc As New XmlDocument()
- doc.Load(XMLDATEI)
- Dim nodes As XmlNodeList = doc.DocumentElement.SelectNodes("/Root")
- For Each node As XmlNode In nodes
- STATIONNO = node.SelectSingleNode("Received/StationNo").InnerText
- RECEIVED_TIMESTAMP = node.SelectSingleNode("Received/ReceivedTimestamp").InnerText
- NUMBER_ABR = node.SelectSingleNode("DailyStatement/@Number").InnerText
- TIMESTAMP_ABR = node.SelectSingleNode("DailyStatement/Timestamp").InnerText
- SERVICETYPE = node.SelectSingleNode("DailyStatement/SalesGroupStatemen/@ServiceType").InnerText
- COMMODITYGROUPNUMBER = node.SelectSingleNode("DailyStatement/SalesGroupStatemen/@CommodityGroupNumber").InnerText
- TIMESTAMP_PRICE = node.SelectSingleNode("DailyStatement/SalesGroupStatemen/Timestamp").InnerText
- UNITPRICE = node.SelectSingleNode("DailyStatement/SalesGroupStatemen/UnitPrice").InnerText
- UNITPRICENEW = node.SelectSingleNode("DailyStatement/SalesGroupStatemen/UnitPriceNew").InnerText
- FINALAMOUNT = node.SelectSingleNode("DailyStatement/SalesGroupStatemen/FinalAmount").InnerText
- FINALQUNATITY = node.SelectSingleNode("DailyStatement/SalesGroupStatemen/FinalQuantity").InnerText
- FORECOURTTYPE = node.SelectSingleNode("DailyStatement/SalesGroupStatemen/ForecourtType").InnerText
- Console.WriteLine("COMMODITYGROUPNUMBER: " + node.SelectSingleNode("DailyStatement/SalesGroupStatemen/@CommodityGroupNumber").InnerText + "ServiceType: " + node.SelectSingleNode("DailyStatement/SalesGroupStatemen/@ServiceType").InnerText)
- Next