如何使用Asp读取远程Xml并有选择的输出?
这是在和朋友Gio交流下,参考网上一些朋友得到的代码,功能是用来读取远程xml并显示,貌似就是简单rss读取的原理
如何选择读取xml中的节点,那就是使用
selectSingleNode
<%
url="http://www.kpiao.com/rss/3g/result.jsp?start=%E4%B8%8A%E6%B5%B7&end=%E6%9D%AD%E5%B7%9E&Submit2=%E7%AB%99%E7%AB%99%E6%9F%A5%E8%AF%A2"
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET",url,False
http.send
Set xml=Server.CreateObject("Microsoft.XMLDOM")
xml.Async=False
xml.ValidateOnParse=False
xml.Load(http.ResponseXML)
If xml.ReadyState>2 Then
Response.Write("获取xml地址:"& url &"<br />")
Response.Write("文档已经准备就绪。状态:"& xml.ReadyState &"<br /><br />")
set obj=xml.selectNodes("//item")
for each b in obj
response.write b.selectSingleNode("no").text&" "
response.write b.selectSingleNode("type").text&"<br />"
next
Else
Response.Write("文档还未准备就绪。状态:"& xml.ReadyState &"<br />")
End If
Set http=Nothing
Set xml=Nothing
%>
url="http://www.kpiao.com/rss/3g/result.jsp?start=%E4%B8%8A%E6%B5%B7&end=%E6%9D%AD%E5%B7%9E&Submit2=%E7%AB%99%E7%AB%99%E6%9F%A5%E8%AF%A2"
Set http=Server.CreateObject("Microsoft.XMLHTTP")
http.Open "GET",url,False
http.send
Set xml=Server.CreateObject("Microsoft.XMLDOM")
xml.Async=False
xml.ValidateOnParse=False
xml.Load(http.ResponseXML)
If xml.ReadyState>2 Then
Response.Write("获取xml地址:"& url &"<br />")
Response.Write("文档已经准备就绪。状态:"& xml.ReadyState &"<br /><br />")
set obj=xml.selectNodes("//item")
for each b in obj
response.write b.selectSingleNode("no").text&" "
response.write b.selectSingleNode("type").text&"<br />"
next
Else
Response.Write("文档还未准备就绪。状态:"& xml.ReadyState &"<br />")
End If
Set http=Nothing
Set xml=Nothing
%>
如需转载请注明文章来源,本文链接: http://icojump.in/?p=96
发表您宝贵的评论