
Question:
I'm trying to use the weatherbug API, but seem to be stuck quite early in the proceedings.
The [very simple] code I tried:
function weather_widget($apikey, $zipcode) { $url = "http://$apikey.api.wxbug.net/getLiveWeatherRSS.aspx?ACode=$apikey&zipcode=$zipcode&unittype=0&outputtype=1"; $contents = file_get_contents($url); $doc = new DOMDocument(); $doc->loadXML($contents); return $doc->getElementsByTagName('aws:weather'); } var_dump(weather_widget($key, $code));
This produced:
object(DOMNodeList)#2 (0) { }
Does XML DOM not work with at tagname that contains :'s?
Solution:1
The aws isn't part of the tagname - it's the namespace.
See getElementsByTagNameNS
http://www.php.net/manual/en/domdocument.getelementsbytagnamens.php
Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
EmoticonEmoticon