asfman
android developer
posts - 90,  comments - 213,  trackbacks - 0
asp中创建xml对象通常使用:CreateObject("Microsoft.XMLDOM")
读取节点:selectSingleNode("nodename")//nodename为节点名。
读取属性:attributes.getNamedItem("attribute")//attribute为节点中所具有的属性名。
加载xml; load(Server.MapPath("data.xml")) 
async 属性表示是否允许异步的下载。

 
引用:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%Response.Charset="UTF-8"%> 
<html>
<title>read xml</title>
<body>
<%
dim node,i,nodecount
set Doc = CreateObject("Microsoft.XMLDOM")
Doc.async = false
Doc.load(Server.MapPath("data.xml")) 
set root = Doc.documentElement
set nodeLis = root.childNodes
nodeCount = nodeLis.length
For i=1 to nodeCount 
set node = nodeLis.nextNode()
set cost = node.attributes.getNamedItem("cost")
%>
第 <%=i%> 条记录:
<table border="1">
<tr> 
<td width="16" rowspan="2"><img src="<%=node.selectSingleNode("img").text%>"/></td>
<td width="17">书名</td>
<td width="48">出版社</td>
<td width="32">价格</td>
</tr>
<tr> 
<td> 
<%=node.selectSingleNode("name").text%>
</td>
<td> 
<%=node.selectSingleNode("publisher").text%>
</td>
<td> 
<%= cost.text%>
</td>
</tr>
</table>
<%
Next
%>
</body>
</html>

 


XML
  
引用:
<?xml version="1.0" encoding="utf-8"?>
<data>
<book cost="56">
<name>Dreamweaver</name>
<publisher>上海科技出版社</publisher>
<img>img/dw.jpg</img>
</book>
<book cost="62">
<name>Flash</name>
<publisher>铁道出版社</publisher>
<img>img/flash.jpg</img>
</book>
<book cost="48">
<name>Firweorks</name>
<publisher>教育出版社</publisher>
<img>img/fw.jpg</img>
</book>
</data>
posted on 2006-08-07 16:54 汪杰 阅读(555) 评论(1)  编辑 收藏 引用 所属分类: xml

FeedBack:
# re: asp读取xml
2006-08-07 16:54 | 汪杰
一个asp读取显示xml子节点数据的问题

<xml>
<test>a</test>
<guest>
<title>aaaa</title>
<info>
<day>2000</day>
<year>20000</year>
</info>
<title>bbbbb</title>
<info>
<day>4444444</day>
<year>1984</year>
</info>
........
</guest>
</xml>

要显示上面这些的有的数据,怎么做<guest></guest>里的数据条数不确定




<%
dim the_text : the_text=""
set blogdom=server.createobject("Microsoft.XMLDOM")
blogdom.async=false
blogdom.load "c:\bloginfo.xml"
set blogchild=blogdom.getElementsByTagName("guest")
for i=0 to blogchild.length-1
for j=0 to blogchild.item(i).childnodes.length-1
the_text=the_text & blogchild.item(i).childnodes(j).text
next
next
response.write the_text
%>  回复  更多评论
  
只有注册用户登录后才能发表评论。

<2006年7月>
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

常用链接

留言簿(15)

随笔分类(1)

随笔档案(90)

文章分类(727)

文章档案(712)

相册

收藏夹

http://blog.csdn.net/prodigynonsense

友情链接

最新随笔

搜索

  •  

积分与排名

  • 积分 - 459351
  • 排名 - 6

最新随笔

最新评论

阅读排行榜

评论排行榜