How to get the tag “” from Yahoo Weather RSS in PHP?

前端 未结 2 1466
臣服心动
臣服心动 2020-12-06 04:06
load(\'http://weather.yahooapis.com/forecastrss?p=VEXX0024&u=c\');
    $channel = $doc->getElementsByTagNa         


        
2条回答
  •  离开以前
    2020-12-06 04:20

    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:

    
    

提交回复
热议问题