注册 登录
编程论坛 ASP技术论坛

XML的问题

pwwshli 发布于 2009-10-13 16:14, 452 次点击
请教群里的高手,我要怎样才能读出下面的XML文档中的内容:
test.xml
  <xml>
  <total>85</total>
  <real_total>50</real_total>
  <item>
  <id>1</id>
  <title>功夫熊猫 nobody</title>
  <author>健力宝官网</author>
  <descp>
  <a href="http://v. title="功夫熊猫 nobody" target="_blank">
  <img src="http://g3. border="0" width="120" height="90" vspace="4" hspace="4" />
  </a>
  <p>健力宝啦啦队 功夫熊猫</p>
  </descp>
  <pv>301406</pv>
  <vid>http://player.
  <pubdate>Mon, 27 Jul 2009 02:58:24 +0800</pubdate>
  </item>
  <item>
  <id>2</id>
  <title>终于等到了Nobody的终极版本,超强!必看!</title>
  <author>健力宝官网</author>
  <descp>
  <a href="http://v. title="终于等到了Nobody的终极版本,超强!必看!" target="_blank">
  <img src="http://g1. border="0" width="120" height="90" vspace="4" hspace="4" />
  </a>
  <p />
  </descp>
  <pv>597</pv>
  <vid>http://player.
  <pubdate>Fri, 24 Jul 2009 07:40:05 +0800</pubdate>
  </item>
  <item>
</xml>

我用的方法读不出来<a>,<img>内的内容:
效果如下:
只有本站会员才能查看附件,请 登录
2 回复
#2
pwwshli2009-10-13 16:16
补充一下:
原代码如下:
<%  
Set newxml=Server.CreateObject("Microsoft.XMLDOM")            
newxml.load(Server.MapPath("test.xml"))                 
Set newlist=newxml.getElementsByTagName("item")            
newint=newlist.length-1
for i=0 To newint
response.write "id:"&newlist.item(i).childNodes.item(0).text&"<br/>"
response.write "title:"&newlist.item(i).childNodes.item(1).text&"<br/>"
response.write "author:"&newlist.item(i).childNodes.item(2).text&"<br/>"
response.write "desc:"&newlist.item(i).childNodes.item(3).text&"<br/>"
response.write "pv:"&newlist.item(i).childNodes.item(4).text&"<br/>"
response.write "vid:"&newlist.item(i).childNodes.item(5).text&"<br/>"
response.write "pubdate:"&newlist.item(i).childNodes.item(6).text&"<br/>"
response.write "<hr>"
next
 %>
#3
yms1232009-10-13 17:34
img属于a的子节点,如果楼主想把img的代码都读出来,记得好像要使用innerText属性,因为text属性是读取像
<abc>asdf</abc>这种情况,而<abc><def src="asdfg"/></abc>这种情况下def为字节点并非文本。
1