Malinowo, php

Projekt #1 – Są już dane pogodowe.

Na szybko. Dodałem kod czytający z yahoo pogodę i wyświetlający ją na moim wirtualnym ekranie. :)

<?php
$result = file_get_contents('http://weather.yahooapis.com/forecastrss?w=523920&u=c');
$xml = simplexml_load_string($result);
$xml->registerXPathNamespace('yweather', 'http://xml.weather.yahoo.com/ns/rss/1.0');
$location = $xml->channel->xpath('yweather:location');
foreach($xml->channel->item as $item){
$current = $item->xpath('yweather:condition');
$forecast = $item->xpath('yweather:forecast');
$current = $current[0];
$output = <<<END
<span>{$current['text']},&nbsp;{$current['temp']}&deg;C</span>
END;
}
echo $output;
?>

Oczywiście plik zaciąga dane pogodowe dla Warszawy, a odpowiada za to parametr w=523920 w pierwszej linii. Dla innego miasta trzeba to zmienić! :)