Tak for linket, men det hjælper mig ikke rigtigt videre.
Problemet er vidst nok at yweather-elementet har et namespace-prefix, hvilket gør at man ikke kan tilgå det på normal vis.
Har forsøgt med nedenstående kode, ingen fejl denne gang, men et tomt output.
$feed = simplexml_load_file('
http://xml.weather.yahoo.com/forecastrss?p=DAXX0009&u=c');
foreach ($feed->item as $item) {
$ns = $item->children('
http://xml.weather.yahoo.com/ns/rss/1.0');
$temp = $ns->condition;
echo $temp[temp];
}
Nogle ideer?
Var-dump ser sådan ud:
object(SimpleXMLElement)#1 (2) { ["@attributes"]=> array(1) { ["version"]=> string(3) "2.0" } ["channel"]=> object(SimpleXMLElement)#2 (8) { ["title"]=> string(31) "Yahoo! Weather - Copenhagen, DA" ["link"]=> string(114) "
http://us.rd.yahoo.com/dailynews/rss/weather/Copenhagen__DA/*http://xml.weather.yahoo.com/forecast/DAXX0009_c.html" ["description"]=> string(33) "Yahoo! Weather for Copenhagen, DA" ["language"]=> string(5) "en-us" ["lastBuildDate"]=> string(29) "Mon, 15 May 2006 6:20 pm CEST" ["ttl"]=> string(2) "60" ["image"]=> object(SimpleXMLElement)#3 (5) { ["title"]=> string(14) "Yahoo! Weather" ["width"]=> string(3) "142" ["height"]=> string(2) "18" ["link"]=> string(25) "
http://weather.yahoo.com/" ["url"]=> string(59) "
http://us.i1.yimg.com/us.yimg.com/i/us/nws/th/main_142b.gif" } ["item"]=> object(SimpleXMLElement)#4 (5) { ["title"]=> string(45) "Conditions for Copenhagen, DA at 6:20 pm CEST" ["link"]=> string(114) "
http://us.rd.yahoo.com/dailynews/rss/weather/Copenhagen__DA/*http://xml.weather.yahoo.com/forecast/DAXX0009_c.html" ["pubDate"]=> string(29) "Mon, 15 May 2006 6:20 pm CEST" ["description"]=> object(SimpleXMLElement)#5 (0) { } ["guid"]=> string(30) "DAXX0009_2006_05_15_18_20_CEST" } } }