I am trying to parse the Yahoo! rss weather feed, specifically their values inside of namespaces, but I can't find the right path to save my life.
I have registered the namespaces, but can't find the right syntax.
Suggestions?
[code]
weather->yweather->location->city}";
?>
=$this->weather->current()->description()?>
="Lat {$this->weather->current()->geo->lat}"?>
[/code]
[xml]
Yahoo! Weather - Memphis, TN
http://us.rd.yahoo.com/dailynews/rss/weather/Memphis__TN/*http://weather.yahoo.com/forecast/38105_f.html
Yahoo! Weather for Memphis, TNen-usMon, 04 Aug 2008 8:53 am CDT60Yahoo! Weather14218
http://weather.yahoo.com
http://l.yimg.com/us.yimg.com/i/us/nws/th/main_142b.gifConditions for Memphis, TN at 8:53 am CDT35.05-90
http://us.rd.yahoo.com/dailynews/rss/weather/Memphis__TN/*http://weather.yahoo.com/forecast/38105_f.html
Mon, 04 Aug 2008 8:53 am CDT Current Conditions:
Fair, 82 F
Some javascript/style in this post has been disabled (why?)
HI Kwylez,
Your problem is that the data for yweather elements is presented as attributes rather than text containing elements. Here's how to get the current weather condition (which is a "text" attribute on the "yweather:condition" element).
Notice how I access attributes by falling back on DOMDocument/DOMElement methods after retrieving the DOM representation of the correct
namespaced element? If you check the RSS form Yahoo are using getting any other data should be a simple copy of the last three lines above.
Thank you sooo much. That helps. I will see if I can figure out the different namespaces inside of the item tag on my own.
Thanks again.
-Cory
On Mon, Aug 4, 2008 at 11:23 AM, Pádraic Brady <[hidden email]> wrote:
HI Kwylez,
Your problem is that the data for yweather elements is presented as attributes rather than text containing elements. Here's how to get the current weather condition (which is a "text" attribute on the "yweather:condition" element).
Notice how I access attributes by falling back on DOMDocument/DOMElement methods after retrieving the DOM representation of the correct
namespaced element? If you check the RSS form Yahoo are using getting any other data should be a simple copy of the last three lines above.