Note that there are some explanatory texts on larger screens.

plurals
  1. PORead Xml using js
    text
    copied!<p>I am reading yahoo weather xml file</p> <pre><code> &lt;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#"&gt; &lt;channel&gt; &lt;title&gt;Yahoo! Weather - Sunnyvale, CA&lt;/title&gt; &lt;link&gt;http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/*http://weather.yahoo.com/forecast/USCA1116_f.html&lt;/link&gt; &lt;description&gt;Yahoo! Weather for Sunnyvale, CA&lt;/description&gt; &lt;language&gt;en-us&lt;/language&gt; &lt;lastBuildDate&gt;Thu, 17 Feb 2011 3:55 am PST&lt;/lastBuildDate&gt; &lt;ttl&gt;60&lt;/ttl&gt; &lt;yweather:location city="Sunnyvale" region="CA" country="United States"/&gt; &lt;yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/&gt; &lt;yweather:wind chill="41" direction="150" speed="7" /&gt; &lt;yweather:atmosphere humidity="86" visibility="10" pressure="29.96" rising="2" /&gt; &lt;yweather:astronomy sunrise="6:54 am" sunset="5:49 pm"/&gt; &lt;image&gt; &lt;title&gt;Yahoo! Weather&lt;/title&gt; &lt;width&gt;142&lt;/width&gt; &lt;height&gt;18&lt;/height&gt; &lt;link&gt;http://weather.yahoo.com&lt;/link&gt; &lt;url&gt;http://l.yimg.com/a/i/brand/purplelogo//uh/us/news-wea.gif&lt;/url&gt; &lt;/image&gt; &lt;item&gt; &lt;title&gt;Conditions for Sunnyvale, CA at 3:55 am PST&lt;/title&gt; &lt;geo:lat&gt;37.37&lt;/geo:lat&gt; &lt;geo:long&gt;-122.04&lt;/geo:long&gt; &lt;link&gt;http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/*http://weather.yahoo.com/forecast/USCA1116_f.html&lt;/link&gt; &lt;pubDate&gt;Thu, 17 Feb 2011 3:55 am PST&lt;/pubDate&gt; &lt;yweather:condition text="Cloudy" code="26" temp="45" date="Thu, 17 Feb 2011 3:55 am PST" /&gt; &lt;description&gt;&lt;![CDATA[ &lt;img src="http://l.yimg.com/a/i/us/we/52/26.gif"/&gt;&lt;br /&gt; &lt;b&gt;Current Conditions:&lt;/b&gt;&lt;br /&gt; Cloudy, 45 F&lt;BR /&gt; &lt;BR /&gt;&lt;b&gt;Forecast:&lt;/b&gt;&lt;BR /&gt; Thu - Rain. High: 54 Low: 44&lt;br /&gt; Fri - Rain. High: 53 Low: 39&lt;br /&gt; &lt;br /&gt; &lt;a href="http://us.rd.yahoo.com/dailynews/rss/weather/Sunnyvale__CA/*http://weather.yahoo.com/forecast/USCA1116_f.html"&gt;Full Forecast at Yahoo! Weather&lt;/a&gt;&lt;BR/&gt;&lt;BR/&gt; (provided by &lt;a href="http://www.weather.com" &gt;The Weather Channel&lt;/a&gt;)&lt;br/&gt; ]]&gt;&lt;/description&gt; &lt;yweather:forecast day="Thu" date="17 Feb 2011" low="44" high="54" text="Rain" code="12" /&gt; &lt;yweather:forecast day="Fri" date="18 Feb 2011" low="39" high="53" text="Rain" code="12" /&gt; &lt;guid isPermaLink="false"&gt;USCA1116_2011_02_17_3_55_PST&lt;/guid&gt; &lt;/item&gt; &lt;/channel&gt; &lt;/rss&gt; </code></pre> <p>Using the following js code</p> <pre><code>var channel = xml.documentElement.getElementsByTagName("channel"); var c = channel.item(0).getElementsByTagName("ttl").item(0).text; </code></pre> <p>I get 60 value for var c. How can i get the "humidity="86" attribute from <code>yweather:atmosphere</code> tag</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload