首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > XML SOAP >

初学者请问:asp读取xml报错的有关问题

2012-02-24 
菜鸟请教:asp读取xml报错的问题!我的网站原有rss的文件rss.xml。http://218.244.47.210/catalog/rss.xml我

菜鸟请教:asp读取xml报错的问题!
我的网站原有rss的文件rss.xml。
http://218.244.47.210/catalog/rss.xml

我现在试着作了一个asp页(http://218.244.47.210/catalog/test3.asp)想把rss里的内容都读取出来。但是刚做了个测试页就开始报错(缺少对象:   '[object] ')。

我的读取代码如下:
<%
Set   Source   =   CreateObject( "Msxml2.DOMDocument.6.0 ")
Source.async   =   false
Source.load(Server.MapPath( "rss.xml "))  
Set   Root   =   Source.documentElement
set   subroot=Root.selectSingleNode( "channel ")
set   allitem=subroot.childNodes
nodeCount   =   allitem.length
'response.write   " <br> "&nodeCount& " <br> "
For   i=1   to   nodeCount
set   node=allitem.nextNode()
response.write   node.selectSingleNode( "link ").text     '就是这行报的错!
next
%>

请高手致点!


[解决办法]
没有必要用nextNode()。
<%
Set Source = CreateObject( "Msxml2.DOMDocument.4.0 ")
Source.async = false
Source.load(Server.MapPath( "rss.xml "))
Set Root = Source.documentElement
'set subroot=Root.selectSingleNode( "channel ")
'set allitem=subroot.childNodes
set allitem=Root.selectNodes( "//item ")
nodeCount = allitem.length
'response.write " <br/> "&nodeCount& " <br/> "
For i=0 to nodeCount-1
'set node=allitem.nextNode()
'response.write node.selectSingleNode( "link ").text '就是这行报的错!
response.write allitem(i).selectSingleNode( "link ").text& " <br> "
next
%>

热点排行