I have been trying to parse and extract some values from xml (starts off as a string) which I retrieved from a web service but i'm struggling to iterate through it. Here is the format of the xml string (sorry it's a bit dense):
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetInstantaneousFlowDataResponse xmlns="http://www.NationalGrid.com/EDP/UI/">
<GetInstantaneousFlowDataResult>
<ReportName xmlns="http://www.NationalGrid.com/EDP/BusinessEntities/Public">string</ReportName>
<PublishedTime xmlns="http://www.NationalGrid.com/EDP/BusinessEntities/Public">dateTime</PublishedTime>
<EDPReportPage xmlns="http://www.NationalGrid.com/EDP/BusinessEntities/Public">
<PageName>string</PageName>
<CurrentGasDay>dateTime</CurrentGasDay>
<EDPEnergyGraphTableCollection>
<EDPEnergyGraphTableBE xsi:nil="true" />
<ItemPosition>1</ItemPosition>
<EDPObjectCollection>
<EDPObjectBE>
<EDPObjectName>ALDBROUGH</EDPObjectName>
<EnergyDataList>
<EDPEnergyDataBE>
<ApplicableAt>2014-09-24T12:00:00</ApplicableAt>
<FlowRate>0</FlowRate>
<QualityIndicator />
<ScheduleTime>2014-09-24T12:12:00</ScheduleTime>
</EDPEnergyDataBE>
</EnergyDataList>
</EDPObjectBE>
<EDPEnergyGraphTableBE xsi:nil="true" />
</EDPEnergyGraphTableCollection>
<NoteCollection>
<EDPNoteBE xsi:nil="true" />
<EDPNoteBE xsi:nil="true" />
</NoteCollection>
</EDPReportPage>
</GetInstantaneousFlowDataResult>
</GetInstantaneousFlowDataResponse>
</soap:Body>
</soap:Envelope>
I was trying to get just the name of each report for the moment then getting the rest of the values later but i'm not sure why it isn't working. This is the code I have been trying to get to work:
Dim xmlDoc As XDocument = XDocument.Parse(xml)
Dim reports = From flowData In xmlDoc...<EDPObjectBE> _
Select flowData
For Each flowData In reports
MsgBox(flowData .<EDPObjectName>.Value)
Next
Here is the answer that I was trying to emulate as it seemed most suitable for what I need: LINQ to XML in VB.NET