Thursday, March 6, 2008

XPath to find an attribute value (1)

The following is the XML which I need to examine:

<?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_c.html</link>

    <description>Yahoo! Weather for Sydney Regional Office, AS</description>

    <language>en-us</language>

    <lastBuildDate>Thu, 06 Mar 2008 9:30 pm AEDT</lastBuildDate>

    <ttl>60</ttl>

    <yweather:location city="Sydney Regional Office" region=""  country="AS"/>

    <yweather:units temperature="C" distance="km" pressure="mb" speed="kph"/>

    <yweather:wind chill="23"  direction="30"  speed="16.09" />

    <yweather:atmosphere humidity="78"  visibility="9.99"  pressure="0"  rising="1" />

    <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 9:30 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_c.html</link>

      <pubDate>Thu, 06 Mar 2008 9:30 pm AEDT</pubDate>

      <yweather:condition  text="Fair"  code="33"  temp="23"  date="Thu, 06 Mar 2008 9:30 pm AEDT" />

      <description>

        <![CDATA[

<img src="http://l.yimg.com/us.yimg.com/i/us/we/52/33.gif"/><br />

<b>Current Conditions:</b><br />

Fair, 23 C<BR />

<BR /><b>Forecast:</b><BR />

Thu - Clear. High: 27 Low: 17<br />

Fri - Mostly Sunny. High: 26 Low: 19<br />

Sat - AM Showers. High: 25 Low: 19<br />

Sun - Sunny. High: 26 Low: 16<br />

Mon - Sunny. High: 26 Low: 16<br />

<br />

<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Sydney_Regional_Office__AS/*http://weather.yahoo.com/forecast/ASXX0274_c.html">Full Forecast at Yahoo! Weather</a><BR/>

(provided by The Weather Channel)<br/>

]]>

      </description>

      <yweather:forecast day="Thu" date="6 Mar 2008" low="17" high="27" text="Clear" code="31" />

      <yweather:forecast day="Fri" date="7 Mar 2008" low="19" high="26" text="Mostly Sunny" code="34" />

      <yweather:forecast day="Sat" date="8 Mar 2008" low="19" high="25" text="AM Showers" code="39" />

      <yweather:forecast day="Sun" date="9 Mar 2008" low="16" high="26" text="Sunny" code="32" />

      <yweather:forecast day="Mon" date="10 Mar 2008" low="16" high="26" text="Sunny" code="32" />

      <guid isPermaLink="false">ASXX0274_2008_03_06_21_30_AEDT</guid>

    </item>

  </channel>

</rss>

<!-- api2.weather.sp1.yahoo.com compressed Thu Mar  6 02:59:57 PST 2008 -->

blog comments powered by Disqus