Hello,
I would like to process a yahoo weather feed with Zend Framework :
Yahoo! Weather - Paris, FR
Retreive the feed is not a problem.
However, i can't get interestings elements like the markup content for :
<yweather:... />
Here's the Php code and the xml file (RSS 2.0 format) produced by yahoo :
PHP Code:
<?php
// http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c
set_include_path("c:\\Program Files\\wamp\\www\\zf\\library\\");
require_once('../../zf/library/Zend/Feed/Rss.php');
try {
$yahooWeatherRss = Zend_Feed::import('http://weather.yahooapis.com/forecastrss?p=FRXX0076&u=c');
// comment récupérer mes éléments ici ??
} catch (Zend_Feed_Exception $e) {
echo "Erreur à l'import du fil : {$e->getMessage()}\n";
exit;
}
?>
Code:
<?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 - Paris, FR</title>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Paris__FR/*http://weather.yahoo.com/forecast/FRXX0076_c.html</link>
<description>Yahoo! Weather for Paris, FR</description>
<language>en-us</language>
<lastBuildDate>Mon, 28 Jan 2008 11:00 pm CET</lastBuildDate>
<ttl>60</ttl>
<yweather:location city="Paris" region="" country="FR"/>
<yweather:units temperature="C" distance="km" pressure="mb" speed="kph"/>
<yweather:wind chill="-2" direction="150" speed="10"/>
<yweather:atmosphere humidity="93" visibility="501" pressure="0" rising="0"/>
<yweather:astronomy sunrise="8:27 am" sunset="5:40 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 Paris, FR at 11:00 pm CET</title>
<geo:lat>48.86</geo:lat>
<geo:long>2.35</geo:long>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Paris__FR/*http://weather.yahoo.com/forecast/FRXX0076_c.html</link>
<pubDate>Mon, 28 Jan 2008 11:00 pm CET</pubDate>
<yweather:condition text="Mostly Cloudy" code="27" temp="1" date="Mon, 28 Jan 2008 11:00 pm CET"/>
<description><![CDATA[
<img src="http://l.yimg.com/us.yimg.com/i/us/we/52/27.gif" /><br />
<b>Current Conditions:</b><br />
Mostly Cloudy, 1 C<BR /><BR />
<b>Forecast:</b><BR />
Mon - Mostly Cloudy. High: 8 Low: 0<br />
Tue - Cloudy. High: 6 Low: 1<br />
<br />
<a href="http://us.rd.yahoo.com/dailynews/rss/weather/Paris__FR/*http://weather.yahoo.com/forecast/FRXX0076_c.html">Full Forecast at Yahoo! Weather</a><BR/>
(provided by The Weather Channel)<br/>
]]></description>
<yweather:forecast day="Mon" date="28 Jan 2008" low="0" high="8" text="Mostly Cloudy" code="27"/>
<yweather:forecast day="Tue" date="29 Jan 2008" low="1" high="6" text="Cloudy" code="26"/>
<guid isPermaLink="false">FRXX0076_2008_01_28_23_0_CET</guid>
</item>
</channel>
</rss>
<!-- p6.weather.re3.yahoo.com compressed/chunked Mon Jan 28 14:23:55 PST 2008 -->
Thanks.
Eric Pommereau