load(\'http://weather.yahooapis.com/forecastrss?p=VEXX0024&u=c\');
$channel = $doc->getElementsByTagNa
Something like:
echo $itemgotten->getElementsByTagNameNS(
"http://xml.weather.yahoo.com/ns/rss/1.0","condition")->item(0)->
getAttribute("temp");
The key is that you have to use getElementsByTagNameNS
instead of getElementsByTagName
and specify "http://xml.weather.yahoo.com/ns/rss/1.0"
as the namespace.
You know yweather
is a shortcut for http://xml.weather.yahoo.com/ns/rss/1.0
because the XML file includes a xmls
attribute:
<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#">
How about:
And if you need to get anything with namespaces, there is corresponding methods ending in NS
.