EDN Admin
Well-known member
New to XPath, etc.... VB.Net Express .Net 4
I have this:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; geonames<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; observation<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; observation<span style="color:Blue; >KBFL 102354Z 33010KT 10SM CLR 35/12 A2969 RMK AO2 WSHFT 2310 SLP046 T03500117 10372 20289 55012 $<span style="color:Blue; </<span style="color:#A31515; observation<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; observationTime<span style="color:Blue; >2011-09-10 23:54:00<span style="color:Blue; </<span style="color:#A31515; observationTime<span style="color:Blue; >
...
<span style="color:Blue; </<span style="color:#A31515; observation<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; geonames<span style="color:Blue; >
[/code]
<br/>
What is the proper XPATH to get to the elements inside the first <observation>?
My VB.Net code:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; For <span style="color:Blue; Each elem <span style="color:Blue; In doc.SelectSingleNode(<span style="color:#A31515; "geonames[observation]").FirstChild.ChildNodes
s &= elem.Name & <span style="color:#A31515; ": " & elem.InnerText & vbCrLf
<span style="color:Blue; Next
[/code]
Seems messy... but I cant get a clean shot at the elements I want to evaluate any other way Ive found. Is there an XPATH expression/other system.xml code that will dig out the data?
FYI the REST call:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim URL <span style="color:Blue; As <span style="color:Blue; String = <span style="color:Blue; String.Format(<span style="color:#A31515; "http://api.geonames.org/findNearByWeatherXML?lat={0}&lng={1}&username=demo", aLatLong(0).Trim, aLatLong(1).Trim)
doc.Load(URL)
[/code]
<br/>
<br/>
<br/>
View the full article
I have this:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; <<span style="color:#A31515; geonames<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; observation<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; observation<span style="color:Blue; >KBFL 102354Z 33010KT 10SM CLR 35/12 A2969 RMK AO2 WSHFT 2310 SLP046 T03500117 10372 20289 55012 $<span style="color:Blue; </<span style="color:#A31515; observation<span style="color:Blue; >
<span style="color:Blue; <<span style="color:#A31515; observationTime<span style="color:Blue; >2011-09-10 23:54:00<span style="color:Blue; </<span style="color:#A31515; observationTime<span style="color:Blue; >
...
<span style="color:Blue; </<span style="color:#A31515; observation<span style="color:Blue; >
<span style="color:Blue; </<span style="color:#A31515; geonames<span style="color:Blue; >
[/code]
<br/>
What is the proper XPATH to get to the elements inside the first <observation>?
My VB.Net code:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; For <span style="color:Blue; Each elem <span style="color:Blue; In doc.SelectSingleNode(<span style="color:#A31515; "geonames[observation]").FirstChild.ChildNodes
s &= elem.Name & <span style="color:#A31515; ": " & elem.InnerText & vbCrLf
<span style="color:Blue; Next
[/code]
Seems messy... but I cant get a clean shot at the elements I want to evaluate any other way Ive found. Is there an XPATH expression/other system.xml code that will dig out the data?
FYI the REST call:
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Dim URL <span style="color:Blue; As <span style="color:Blue; String = <span style="color:Blue; String.Format(<span style="color:#A31515; "http://api.geonames.org/findNearByWeatherXML?lat={0}&lng={1}&username=demo", aLatLong(0).Trim, aLatLong(1).Trim)
doc.Load(URL)
[/code]
<br/>
<br/>
<br/>
View the full article