PHP XML DOM-getElementsByTagName
我试图使用weatherbug API,但似乎在程序的早期就被卡住了 我尝试的[非常简单]代码:PHP XML DOM-getElementsByTagName,php,xml,xmldom,Php,Xml,Xmldom,我试图使用weatherbug API,但似乎在程序的早期就被卡住了 我尝试的[非常简单]代码: function weather_widget($apikey, $zipcode) { $url = "http://$apikey.api.wxbug.net/getLiveWeatherRSS.aspx?ACode=$apikey&zipcode=$zipcode&unittype=0&outputtype=1"; $contents = file_get_co
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));
这产生了:
object(DOMNodeList)#2 (0) { }
XML DOM是否不适用于包含以下内容的at标记名?aws不是标记名的一部分,而是名称空间 请参见
GetElementsByTagnames
我会做一些像GetElementsByTagnames(“天气”)这样的事情吗;?因为那不管用