1. 论坛系统升级为Xenforo,欢迎大家测试!
    排除公告

幫忙看看這段 ASP 代碼有什么問題吧

本帖由 不学无术 于 2008-08-13 发布。版面名称:后端开发

  1. 不学无术

    不学无术 Ulysses 的元神

    注册:
    2005-08-31
    帖子:
    16,714
    赞:
    39
    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 返回的沒問題。
     
  2. 不学无术

    不学无术 Ulysses 的元神

    注册:
    2005-08-31
    帖子:
    16,714
    赞:
    39
    實際上返回的 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>
     
  3. 不学无术

    不学无术 Ulysses 的元神

    注册:
    2005-08-31
    帖子:
    16,714
    赞:
    39
    查手冊,自己解決。

    修改

    PHP:
    xml.Load(http.ResponseXML) 
    為

    PHP:
    xml.LoadXML(http.ResponseText) 
     
  4. webren

    webren New Member

    注册:
    2008-09-06
    帖子:
    2,934
    赞:
    0
    不要急一会就好了