以文本方式查看主题

-  ╋艺 镇╋  (http://wdystv.com/bbs/index.asp)
--  ┣◇网站建设&Web语言  (http://wdystv.com/bbs/list.asp?boardid=4)
----  asp读取xml的两种方法  (http://wdystv.com/bbs/dispbbs.asp?boardid=4&id=4569)

--  作者:admin
--  发布时间:2015/6/6 12:25:52
--  asp读取xml的两种方法
 

读取固定xml文件:

 

<?xml version="1.0" encoding="utf-8"?>
<xml>
<AO>
  <string>A</string>
  <string>B</string>
  <string>C</string>
  <string>D</string>
  <string>E</string>
</AO>
</xml>

 

<%
Set myxml=Server.CreateObject("Microsoft.XMLDOM")
    myxml.load(Server.MapPath("test.xml"))
Set myroot=myxml.documentElement.selectSingleNode("AO")
Dim lenth:lenth=myroot.childNodes.length\'节点数
For i=0 To lenth-1
  Response.Write(myroot.childNodes.item(i).text)
Next

set myroot=nothing
set myxml=nothing
%>

 

读取url地址返回的xml

<%
myxml="http://api.y.joy.cn/list?type=2&sid=1886715&count=100&page=1&format=xml&key=83af09d2993048abb6f1de1efe73205a&uid=1555851259"
set xml = server.CreateObject("Microsoft.XMLDOM")
xml.async = "false"
xml.resolveExternals = "false"
xml.setProperty "ServerHTTPRequest", true
xml.load(myxml)
   Set objNodes = xml.getElementsByTagName("video")
For i = 0 to objNodes.length - 1
    Response.write "<li><a href=\'"&Trim(objNodes(i).selectSingleNode("Fvideo_id").Text)&"\'>"&Trim(objNodes(i).selectSingleNode("Ftitle").Text) &"</a></li>"
Next
%>


http://www.cnblogs.com/ycsfwhh/archive/2012/07/11/2586436.html