读取XML文件出错,在线等!
程序源码:
<%
dim xml,objNode,objAtr,nCntChd,nCntAtr
Set xml=Server.CreateObject( "Microsoft.XMLDOM ")
xml.Async=False
xml.Load(Server.MapPath( "aspreadxml.xml "))
Set objNode=xml.documentElement
nCntChd=objNode.ChildNodes.length-1 '这一行出错,提示缺少对象
for i=0 to nCntChd
set objAtr=objNode.ChildNodes.item(i)
nCntAtr=objAtr.Attributes.length-1
for j=0 to nCntAtr
response.write objAtr.Attributes.item(j).Text& " <br> "
next
response.write " <br> "
next
Set objAtr=Nothing
Set objNode=Nothing
Set xml=Nothing
%>
aspreadxml.xml
<?xml version= "1.0 " encoding= "utf-8 " ?>
<root>
<row ID= "1 " COMPNAME= "过桥轩 " ADDR= "广东省广州市越秀区北京路 " 邮编= "510000 " TEL= "8620-8333 " PRODSERV= "经营面 " 经济行业= "粥粉面店 " 省份= "广东省 " 地市= "广州市 " 区域= "越秀区 " visit= "0 " 优先级= "9999999999 " zhuangtai= "最新 "/>
<row ID= "2 " COMPNAME= "周仔 " ADDR= "广东省广州市 " 邮编= "510000 " TEL= "8620-8330 " PRODSERV= "经营快餐饮食 " 经济行业= "快餐 " 省份= "广东省 " 地市= "广州市 " 区域= "越秀区 " visit= "0 " 优先级= "9999999999 " zhuangtai= "最新 "/>
<row ID= "3 " COMPNAME= "香菜馆 " ADDR= "广东省广州市越秀区 " 邮编= "510000 " TEL= "8620-837 " PRODSERV= "经营湘菜 " 经济行业= "湘菜 " 省份= "广东省 " 地市= "广州市 " 区域= "越秀区 " visit= "0 " 优先级= "9999999999 " zhuangtai= "最新 "/>
</root>
在执行这段代码时出错,但是不知道是什么原因,刚刚开始学习,还请各位大侠多多指教^_^
------解决方案--------------------要么存为utf-8格式的xml文档,要么改:edcoding= "gb2312 "