菜鸟请教: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
%>