Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-29-2008, 08:38 PM
Junior Member
 
Join Date: Jan 2008
Posts: 1
Default Feed and Yahoo weather

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-14-2008, 07:52 PM
Junior Member
 
Join Date: Jun 2008
Posts: 4
Red face When a Tiger comes

Two guys were walking through the jungle. All of a sudden, a tiger appears from a distance, running towards them. One of the guys takes out a pair of "Nikes" from his bag and starts to put them on. The other guy with a surprised look and exclaims, "Do you think you will run faster than the tiger with those?"His friend replies: "I don't have to out run it, I just have to run faster than you."----------------------------------Do you look for free wow gold? Welcome to our WoW gold website:1.WoW gold,2.WoW gold,
__________________
Free WoW gold..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-30-2008, 05:01 PM
Junior Member
 
Join Date: Jul 2008
Posts: 1
Default Hi, eric.pommereau, I encounter the same problem

What's more, I can't get rss/channel/item/description neither. When I code

PHP Code:
echo $yahooWeatherRss ->item->description(); 
I get "Yahoo! Weather for Detroit, MI", the content of rss/channel/description element.

I have used MagpieRSS, a RSS parser, it can get "<description><![CDATA[..."
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-05-2008, 07:48 AM
Junior Member
 
Join Date: Feb 2008
Posts: 6
Default I hope this is the answer to your question

Zend_Feed::registerNamespace('yweather','http://xml.weather.yahoo.com/ns/rss/1.0');
$feed = Zend_Feed::import('http://xml.weather.yahoo.com/forecastrss?p=EIXX0014&u=c');

$condition = $feed->current()->{'yweather:condition'};
$text = $condition->getDOM()->getAttribute('text');
var_dump($text);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:21 PM.