1

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_contents($url);
  $doc = new DOMDocument();
  $doc->loadXML($contents);
  return $doc->getElementsByTagName('aws:weather');
}

var_dump(weather_widget($key, $code));

これにより、次のものが生成されました。

object(DOMNodeList)#2 (0) { }

: を含む at tagname では XML DOM は機能しませんか?

4

1 に答える 1

2

awsはタグ名の一部ではなく、名前空間です。

見るgetElementsByTagNameNS

http://www.php.net/manual/en/domdocument.getelementsbytagnamens.php

于 2010-07-06T00:51:30.017 に答える