FredAsterr
Power Member
Boas algumem sabe como pôr resultados de meteorologia no meu proprio site?
foreach ($rss->xpath('//description') as $description)
{
echo $description;
}
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<rss version="2.0" xmlns:yweather="[URL]http://xml.weather.yahoo.com/ns/rss/1.0[/URL]" xmlns:geo="[URL]http://www.w3.org/2003/01/geo/wgs84_pos[/URL]#">
<channel>
<title>Yahoo! Weather - Leiria, PO</title>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Leiria__PO/*http://weather.yahoo.com/forecast/POXX0058_c.html</link>
<description>Yahoo! Weather for Leiria, PO</description>
<language>en-us</language>
<lastBuildDate>Sat, 11 Oct 2008 5:00 pm WEST</lastBuildDate>
<ttl>60</ttl>
<yweather:location city="Leiria" region="" country="PO"/>
<yweather:units temperature="C" distance="km" pressure="mb" speed="kph"/>
<yweather:wind chill="22" direction="70" speed="9.66" />
<yweather:atmosphere humidity="60" visibility="9.99" pressure="0" rising="0" />
<yweather:astronomy sunrise="7:41 am" sunset="7:01 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 Leiria, PO at 5:00 pm WEST</title>
<geo:lat>39.75</geo:lat>
<geo:long>-8.78</geo:long>
<link>http://us.rd.yahoo.com/dailynews/rss/weather/Leiria__PO/*http://weather.yahoo.com/forecast/POXX0058_c.html</link>
<pubDate>Sat, 11 Oct 2008 5:00 pm WEST</pubDate>
<yweather:condition text="Partly Cloudy" code="30" temp="22" date="Sat, 11 Oct 2008 5:00 pm WEST" />
<description><![CDATA[
<img src="[URL]http://l.yimg.com/us.yimg.com/i/us/we/52/30.gif"/><br[/URL] />
<b>Current Conditions:</b><br />
Partly Cloudy, 22 C<BR />
<BR /><b>Forecast:</b><BR />
Sat - Rain. High: 24 Low: 13<br />
Sun - PM Light Rain. High: 23 Low: 11<br />
<br />
<a href="[URL]http://us.rd.yahoo.com/dailynews/rss/weather/Leiria__PO/*http://weather.yahoo.com/forecast/POXX0058_c.html">Full[/URL] Forecast at Yahoo! Weather</a><BR/>
(provided by The Weather Channel)<br/>
]]></description>
<yweather:forecast day="Sat" date="11 Oct 2008" low="13" high="24" text="Rain" code="12" />
<yweather:forecast day="Sun" date="12 Oct 2008" low="11" high="23" text="PM Light Rain" code="11" />
<guid isPermaLink="false">POXX0058_2008_10_11_17_00_WEST</guid>
</item>
</channel>
</rss><!-- api1.weather.re4.yahoo.com compressed/chunked Sat Oct 11 10:21:02 PDT 2008 -->
//condition/@temp
//condition/@code
<?php // Load and parse the XML document
$rss = simplexml_load_file('http://xml.weather.yahoo.com/forecastrss?p=POXX0016&u=c');
$title = $rss->channel->title;
?>
<html xml:lang="en" lang="en">
<head>
<title><?php echo $title; ?></title>
</head>
<body>
<h1><?php echo $title; ?></h1>
<?php
foreach ($rss->channel->item as $item) {
echo "<h2><a href='" . $item->link . "'>" . $item->title . "</a></h2>";
echo "<p>" . $item->description . "</p>";
$teste = $rss->channel->lastBuildDate;
$teste2 = $rss->channel->description ;
echo $teste2 ;
echo $teste ;
}
?>
</body>
</html>
$rss->xpath('//condition/@code');