1
我试图使用weatherbug API,但似乎在程序中相当早。PHP XML DOM - getElementsByTagName
的[非常简单]代码我想:
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不包含标记名一起工作:的?
所以我会做类似getElementsByTagNameNS( 'http://www.aws.com/aws', '天气');? 因为这是行不通的 – skeggse 2010-07-06 04:35:34