利用ResponseXML的方法調(diào)用163天氣預(yù)報(bào)
網(wǎng)絡(luò) 2009/1/23 9:46:38 深山行者 字體:
大 中 小 瀏覽 14225
以下是引用片段:
<!-- 以下是抓取的XML源,http://www.163.com/weatherxml/58044.xml
<?xml version="1.0" encoding="GBK"?> <root> <weather c="連云港" city="58044" qx="陰轉(zhuǎn)晴" wd="-7℃~-2℃" fl="6~7級(jí)" qximg="02.gif,00.gif" lk="1級(jí) 干燥 晴天,雖然天氣有點(diǎn)涼,但其它條件適宜,路面比較干燥,路況較好。 "/> </root> --> <% url = "http://www.163.com/weatherxml/58044.xml" ' 58044 是連云港相對(duì)應(yīng)的天氣預(yù)報(bào)碼 Set http=Server.CreateObject("Microsoft.XMLHTTP") http.Open "GET",url,False http.send Set xml=Server.CreateObject("Microsoft.XMLDOM") xml.Async=true xml.ValidateOnParse=False xml.Load(http.ResponseXML) If xml.ReadyState>2 Then Response.Write("文檔已經(jīng)準(zhǔn)備就緒。狀態(tài):"& xml.ReadyState &"<br>") '這句可不加 set res = xml.selectSingleNode("http://weather") Response.Write res.getAttribute("c") Response.Write " " Response.Write res.getAttribute("wd") Response.Write " " Response.Write res.getAttribute("qx") Response.Write " " Response.Write res.getAttribute("fl") Response.Write " " tqimg = split(res.getAttribute("qximg"),",") '以下為顯示天氣小圖標(biāo) if tqimg(0) <> "" then Response.Write "<img src='http://news.163.com/img/logo/"& tqimg(0) &"'>" elseif tqimg(1) <> "" then Response.Write "<img src='http://news.163.com/img/logo/"& tqimg(1) &"'>" else response.Write "" end if Response.Write "<br>" End if
Set oNode = Nothing Set oDoc = Nothing %>
|
- 相關(guān)閱讀
- 中國(guó)大宗資產(chǎn)交易網(wǎng)
- ASP和AJAX應(yīng)用一例,檢測(cè)注冊(cè)用戶是否有效
- 防止 IE 瀏覽器被黑的技巧十則
- 利用CSS制作的網(wǎng)站中新聞文章列表效果
- 實(shí)時(shí)輸入數(shù)字自動(dòng)轉(zhuǎn)換為貨幣形式并計(jì)算
- 過(guò)濾輸入字符串中的危險(xiǎn)符號(hào)
- 關(guān)于網(wǎng)頁(yè)中pt和px的單位換算!
- asp利用XMLHTTP加載動(dòng)態(tài)頁(yè)面并且生成靜態(tài)頁(yè)面
- 共有0條關(guān)于《利用ResponseXML的方法調(diào)用163天氣預(yù)報(bào)》的評(píng)論
- 發(fā)表評(píng)論