Do not use on any
shared computer
September 6, 2008 03:28pm pdt
 
[x]
Attachment Details

How do I find attributes using xpath?

Tags: xpath, xml, vb.net
I want to get the attribute value of the first yweather:forecast node in the code snippet.

I've already got it using:
 Dim xml As String = GetXML(RSS_URL)
        Dim dom As XmlDocument = New XmlDocument
        dom.LoadXml(xml)
Dim forecastPath As String = "/rss/channel/item/*[local-name()='forecast']"
Dim low As String = dom.SelectSingleNode(forecastPath).Attributes("low").Value

my question is how do I get the whole path without using the Attributes("low").Value?
How do I get the whole path including low attribute just from the forecastPath?

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<rss version="2.0" xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#">
<channel>
 
<title>Yahoo! Weather - Sydney Regional Office, AS</title>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Sydney_Regional_Office__AS/*http://weather.yahoo.com/forecast/ASXX0274_f.html</link>
<description>Yahoo! Weather for Sydney Regional Office, AS</description>
<language>en-us</language>
<lastBuildDate>Thu, 06 Mar 2008 3:00 pm AEDT</lastBuildDate>
<ttl>60</ttl>
<yweather:location city="Sydney Regional Office" region=""   country="AS"/>
<yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/>
<yweather:wind chill="81"   direction="40"   speed="20" />
<yweather:atmosphere humidity="54"  visibility="6.21"  pressure="30.09"  rising="2" />
<yweather:astronomy sunrise="6:47 am"   sunset="7:25 pm"/>
<image>
<title>Yahoo! Weather</title>
<width>142</width>
<height>18</height>
<link>http://weather.yahoo.com</link>
<url>http://l.yimg.com/us.yimg.com/i/us/nws/th/main_142b.gif</url>
</image>
<item>
<title>Conditions for Sydney Regional Office, AS at 3:00 pm AEDT</title>
<geo:lat>-33.85</geo:lat>
<geo:long>151.2</geo:long>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Sydney_Regional_Office__AS/*http://weather.yahoo.com/forecast/ASXX0274_f.html</link>
<pubDate>Thu, 06 Mar 2008 3:00 pm AEDT</pubDate>
<yweather:condition  text="Fair"  code="34"  temp="81"  date="Thu, 06 Mar 2008 3:00 pm AEDT" />
<description><![CDATA[
<img src="http://l.yimg.com/us.yimg.com/i/us/we/52/34.gif"/><br />
<b>Current Conditions:</b><br />
Fair, 81 F<BR />
<BR /><b>Forecast:</b><BR />
Thu - Clear. High: 80 Low: 63<br />
Fri - Mostly Sunny. High: 78 Low: 66<br />
Sat - AM Showers. High: 77 Low: 66<br />
Sun - Sunny. High: 78 Low: 60<br />
Mon - Sunny. High: 78 Low: 61<br />
<br />
<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Sydney_Regional_Office__AS/*http://weather.yahoo.com/forecast/ASXX0274_f.html">Full Forecast at Yahoo! Weather</a><BR/>
(provided by The Weather Channel)<br/>
]]></description>
<yweather:forecast day="Thu" date="6 Mar 2008" low="63" high="80" text="Clear" code="31" />
<yweather:forecast day="Fri" date="7 Mar 2008" low="66" high="78" text="Mostly Sunny" code="34" />
<yweather:forecast day="Sat" date="8 Mar 2008" low="66" high="77" text="AM Showers" code="39" />
<yweather:forecast day="Sun" date="9 Mar 2008" low="60" high="78" text="Sunny" code="32" />
<yweather:forecast day="Mon" date="10 Mar 2008" low="61" high="78" text="Sunny" code="32" />
<guid isPermaLink="false">ASXX0274_2008_03_06_15_00_AEDT</guid>
</item>
</channel>
</rss><!-- api4.weather.sp1.yahoo.com compressed Wed Mar  5 20:31:12 PST 2008 -->
Start your free trial to view this solution
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Question Stats
Zone: Web Development
Question Asked By: fuchangmiao
Solution Provided By: Gertone
Participating Experts: 2
Solution Grade: A
Views: 88
Translate:
Loading Advertisement...
 
[+][-]Accepted Solution by Gertone

Rank: Genius

Accepted Solution by Gertone:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Expert Comment by raja_ind82

Rank: Master

Expert Comment by raja_ind82:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628