asp读取XML报错:缺少对像
Dim oXML,O,oXMLRoot,oXMLitems,oXMLitem,oXMLLinks,iLength,i
Set oXML=CreateObject( "Microsoft.XMLDOM ")
oXML.load ( "e:\zz.xml ")
Set oXMLRoot=oXML.documentElement
Set oXMLItems = oXMLRoot.selectNodes( "MentList ") //本行报错
set oXMLLinks = oXMLItems(0).selectNodes( "Link ")
iLength=oXMLLinks.length-1
For i = 0 To iLength
Set oXMLItem = oXMLLinks.item(i)
Response.Write oXMLitem.GetAttribute( "ID ")
Response.write oXMLItem.selectSingleNode( "Name ").text
Response.write oXMLItem.selectSingleNode( "URL ").text
Next
Set oXMLItem = Nothing
Set oXMLLinks = Nothing
Set oXMLItems = Nothing
Set oXMLRoot = Nothing
Set oXML = Nothing
以上代码是我从网上拷下来的,曾经运行正确,但现在用又报以下错误了,不知怎么解决:
错误类型:
Microsoft VBScript 运行时错误 (0x800A01A8)
缺少对象
/zztest.asp, 第 106 行
浏览器类型:
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Maxthon; TencentTraveler ; .NET CLR 1.1.4322)
------解决方案--------------------littlepig991(朱朱) ( ) 信誉:100 Blog 2007-03-26 10:45:18 得分: 0
头文件已经设定了UTF-8
<meta http-equiv= "Content-Type " content= "text/html; charset=utf_8 " />
还有
106行代码就是上面注释 "//代码出错 "那一行,就是这一行:
Set oXMLItems = oXMLRoot.selectNodes( "MentList ") //本行报错
-----------------------
我问你的xml文件是用utf-8编码保存的吗
------解决方案--------------------打开XML文件 另存为UTF_8的格式,试试看。
------解决方案--------------------文件头与保存的文件格式不同.你在浏览器里直接访问xml试试,如果能正常显示,xml就是正确的.
需要你用文本编辑器另存为utf-8格式的.xml