I have been learning VB.NET and am currently having troubles retrieving data from an XML file. I'm trying to keep the code as simple as possible as I only need to select single items from an XML file, not rows of data.
The XML file contains:
<CurrentPeakUsage xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://au.com.amnet.memberutils/">
<Period>
<Summary xmlns="http://amcom.com.au/UsageWebServices">
<Customer>48413</Customer>
<Start>2010-07-19T00:00:00</Start>
<Finish>2010-08-19T00:00:00</Finish>
<PeakOtherOctetsIn>10543479372</PeakOtherOctetsIn>
<PeakOtherOctetsOut>2469179785</PeakOtherOctetsOut>
<PeakPeerOctetsIn>963088543</PeakPeerOctetsIn>
<PeakPeerOctetsOut>51151688</PeakPeerOctetsOut>
<OffpeakOtherOctetsIn>6651739048</OffpeakOtherOctetsIn>
<OffpeakOtherOctetsOut>1489804526</OffpeakOtherOctetsOut>
<OffpeakPeerOctetsIn>319362717</OffpeakPeerOctetsIn>
<OffpeakPeerOctetsOut>39202998</OffpeakPeerOctetsOut>
</Summary>
<RateLimits xmlns="http://amcom.com.au/UsageWebServices" />
</Period>
<AllowanceList>
<RateGroupName xmlns="http://amcom.com.au/UsageWebServices">ADSL 2+ Enabled 45G/65G - $49.00</RateGroupName>
<Allowances xmlns="http://amcom.com.au/UsageWebServices">
<Allowance>
<Name>Off-Peak Basic</Name>
<OctetsIn>65000000000</OctetsIn>
<OctetsOut xsi:nil="true" />
<Period>Offpeak</Period>
<Class>Other</Class>
</Allowance>
<Allowance>
<Name>Off-Peak Peering</Name>
<OctetsIn>130000000000</OctetsIn>
<OctetsOut xsi:nil="true" />
<Period>Offpeak</Period>
<Class>Peer</Class>
</Allowance>
<Allowance>
<Name>Peak Basic</Name>
<OctetsIn>45000000000</OctetsIn>
<OctetsOut xsi:nil="true" />
<Period>Peak</Period>
<Class>Other</Class>
</Allowance>
<Allowance>
<Name>Peak Peering</Name>
<OctetsIn>90000000000</OctetsIn>
<OctetsOut xsi:nil="true" />
<Period>Peak</Period>
<Class>Peer</Class>
</Allowance>
</Allowances>
</AllowanceList>
</CurrentPeakUsage>
My code contains:
Dim xmlData As XDocument = XDocument.Load("C:\data.xml")
Dim xmlContents As String = xmlData...<Customer>.Value
TextBox1.Text = xmlContents
MsgBox(xmlData.ToString)
While the msgbox will contain the entire XML document, so it is loading correctly, I can't pull the single element value. Am I understanding Xdocuments and XML data handling in VB.NET completely wrong?