I have an XML feed I'm trying to get some data from in Excel. Here's the XML:
<rss xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" version="2.0"> <channel> <title>Yahoo! Weather - Los Angeles, CA</title> <link> http://us.rd.yahoo.com/dailynews/rss/weather/Los_Angeles__CA/*http://weather.yahoo.com/forecast/USCA0638_f.html </link> <description>Yahoo! Weather for Los Angeles, CA</description> <language>en-us</language> <lastBuildDate>Wed, 26 Aug 2015 9:47 am PDT</lastBuildDate> <ttl>60</ttl> <yweather:location city="Los Angeles" region="CA" country="US"/> <yweather:units temperature="F" distance="mi" pressure="in" speed="mph"/> <yweather:wind chill="84" direction="0" speed="0"/> <yweather:atmosphere humidity="55" visibility="7" pressure="29.97" rising="0"/> <yweather:astronomy sunrise="6:20 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/a/i/brand/purplelogo//uh/us/news-wea.gif </url> </image> <item> <title>Conditions for Los Angeles, CA at 9:47 am PDT</title> <geo:lat>34.05</geo:lat> <geo:long>-118.23</geo:long> <link> http://us.rd.yahoo.com/dailynews/rss/weather/Los_Angeles__CA/*http://weather.yahoo.com/forecast/USCA0638_f.html </link> <pubDate>Wed, 26 Aug 2015 9:47 am PDT</pubDate> <yweather:condition text="Fair" code="34" temp="84" date="Wed, 26 Aug 2015 9:47 am PDT"/> <description> <![CDATA[ <img src="http://l.yimg.com/a/i/us/we/52/34.gif"/><br /> <b>Current Conditions:</b><br /> Fair, 84 F<BR /> <BR /><b>Forecast:</b><BR /> Wed - Mostly Sunny. High: 89 Low: 71<br /> Thu - Sunny. High: 89 Low: 72<br /> Fri - Sunny. High: 92 Low: 71<br /> Sat - Mostly Sunny. High: 88 Low: 69<br /> Sun - Mostly Sunny. High: 82 Low: 66<br /> <br /> <a href="http://us.rd.yahoo.com/dailynews/rss/weather/Los_Angeles__CA/*http://weather.yahoo.com/forecast/USCA0638_f.html">Full Forecast at Yahoo! Weather</a><BR/><BR/> (provided by <a href="http://www.weather.com" >The Weather Channel</a>)<br/> ]]> </description> <yweather:forecast day="Wed" date="26 Aug 2015" low="71" high="89" text="Mostly Sunny" code="34"/> <yweather:forecast day="Thu" date="27 Aug 2015" low="72" high="89" text="Sunny" code="32"/> <yweather:forecast day="Fri" date="28 Aug 2015" low="71" high="92" text="Sunny" code="32"/> <yweather:forecast day="Sat" date="29 Aug 2015" low="69" high="88" text="Mostly Sunny" code="34"/> <yweather:forecast day="Sun" date="30 Aug 2015" low="66" high="82" text="Mostly Sunny" code="34"/> <guid isPermaLink="false">USCA0638_2015_08_30_7_00_PDT</guid> </item> </channel> </rss> <!-- fan1591.sports.bf1.yahoo.com Wed Aug 26 10:09:26 PDT 2015 -->
How do I get the elements for the yweather:condition
, as I'm trying to get the value for "temp"
. Or, for that matter, how do I get any of the info between < ... >
, like yweather:forecast
's "high", "low", etc?
I know how to get child elements of more "pure" XML documents - for example, this XML I am able to parse out info with the following:
Set resultnodes = oXMLFile.SelectNodes("/GeocodeResponse/result") For Each n In resultnodes Set latitudenodes = n.SelectSingleNode("geometry/location/lat") Set LongitudeNodes = n.SelectSingleNode("geometry/location/lng") Set addressNodes = n.SelectSingleNode("formatted_address") Set countyNodes = n.SelectSingleNode("address_component[type='administrative_area_level_2']/long_name") If Not latitudenodes Is Nothing Then latitude = latitudenodes.Text If Not LongitudeNodes Is Nothing Then longitude = LongitudeNodes.Text If Not addressNodes Is Nothing Then altAddress = addressNodes.Text
But using something like that isn't working with the Yahoo one. I think/know it's because their XML is laid out differently - they have text and quotes, whereas the Google one is just the tags with the value between ("Pennsylvania Ave SE").
How can I do the same with the Yahoo one? (What's that type of XML called, if it has a different technical name?).
Thanks for any ideas!
Edit: Note, I just tried and I can get the "" and "" values, since they follow my pattern I use with Google...it's the values that are inside < ... >
that I'm unsure how to pull out.