asp操作xml的问题,,急,,在线等,

来源:百度知道 编辑:UC知道 时间:2024/06/05 05:05:09
下面是data.xml文件的内容:
<?xml version="1.0" encoding="utf-8"?><data>
<item id="1" url="http://www.lanrentuku.com/" target="_blank" img="images/d784976416a1345cbc12131a9a595c9d.jpg" thumb="images/5b2f90fada64e44e7a0323a48812753b.jpg" />
<item id="2" url="http://www.lanrentuku.com/" target="_blank" img="images/b606c9322dbc0b5e181df4edabcd4113.jpg" thumb="images/fcd1ef11d1f078cb45d52cba51c02aaa.jpg" />
<item id="3" url="http://www.lanrentuku.com/" target="_blank" img="images/21c3adda3e69f54d85649c030481cb30.jpg" thumb="images/352bfe727650f03f

dim objXML
dim objDataInfo
set objXML=server.CreateObject("Msxml2.DOMDocument")
objXML.async=false
if objXML.load(server.MapPath("/data.xml")) then
set objDataInfo=objXML.GetElementsByTagName("data/item")
else
Response.write("”/data.xml“加载错误!")
end if
objDatainfo就是节点名称,你再判断它是等于“img”、“url”还是“thumb”,再通过objDataInfo.item(i).getAttribute("?")得到?的内容。