PHP: Set http = Server.CreateObject("Microsoft.XMLHTTP") http.Open "GET", "http://www.blogweather.net/getweatherxml.aspx?bw_pkid=W10272", False http.Send() If http.Status = 200 Then Set xml = Server.CreateObject("Microsoft.XMLDOM") xml.Async = False xml.ValidateOnParse = False xml.Load(http.ResponseXML) Set root = xml.documentElement If IsObject(root) Then Set nodes = xml.getElementsByTagName("style") Response.Write(nodes.Length) End If End If 輸出的結果為 0 。 而且奇怪的是,IsObject(root) 判斷為 True,但是如果我用 PHP: Set nodes = root.getElementsByTagName("style") 提示 對象不存在:'root' 崩潰中。 測試,http 返回的沒問題。
實際上返回的 XML 數據如下: PHP: <?xml version='1.0' encoding='utf-8' ?><blogweather> <userinfo> <style>miniweather</style> <lang>TChinese</lang> <temp>c</temp> <icon>wicon_2</icon> <color>/images/topbackline_Blue.gif</color> <sign>天氣預告</sign> <weburl></weburl> <bw_pkid>W10272</bw_pkid> <city_pkid>C1003201</city_pkid> </userinfo> <weatherds> <cityname>香港</cityname> <date1>2008-08-13</date1> <date2>2008-08-14</date2> <date3>2008-08-15</date3> <week1>星期三</week1> <week2>星期四</week2> <week3>星期五</week3> <weather1>多雲</weather1> <weather2>晴</weather2> <weather3>晴</weather3> <img1>/images/wicon_flash/duoyun.swf</img1> <img2>/images/wicon_flash/qing.swf</img2> <img3>/images/wicon_flash/qing.swf</img3> <temp1>32℃~27℃</temp1> <temp2>32℃~27℃</temp2> <temp3>33℃~28℃</temp3> <windpower1>南 3-4</windpower1> <windpower2>西南 3-4</windpower2> <windpower3>西南 3-4</windpower3> <tinyurl></tinyurl> <costtime>0</costtime> </weatherds></blogweather>