Getting a value from a XML docuemtn

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello,
Apologies for my lack of knowledge in this area in advance...
Basically, I am getting XML and parsing it using XElement.Parse but I am finding it impossible to get at a particular value...
The xml is here:
http://www.yournavigation.org/api/1.0/gosmore.php?format=kml&flat=51.4835299&flon=-3.1836873&tlat=51.4043548&tlon=-3.2690216&v=motorcar&fast=1&layer=mapnik http://www.yournavigation.org/api/1.0/gosmore.php?format=kml&flat=51.4835299&flon=-3.1836873&tlat=51.4043548&tlon=-3.2690216&v=motorcar&fast=1&layer=mapnik
I am trying to get at the <distance> value.
I have tried the following but none of them work...
<pre class="prettyprint lang-vb Public Class GetRouteResults
Private RawData As XElement

Public distance As Long

Public Sub New(ByVal rawDataString As String)
Me.RawData = XElement.Parse(rawDataString)
distance = Me.RawData.Element("distance").Value
distance = Me.RawData.Element("Document").Attribute("distance").Value
distance = Me.RawData.Element("Document").Element("distance").Value
distance = Me.RawData.Element("kml").Element("Document").Element("distance").Value
distance = Me.RawData.Element("kml").Element("Document").Attribute("distance").Value
distance = Me.RawData.Element("kml").Element("Document").Attribute("distance").Value
End Sub
End Class[/code]
can anyone help please?
Thanks

View the full article
 
Back
Top