asp加载XML问题?

wode421898419 2010-10-26 11:06:32
s="<root><booklist><book name='xml' /><book id='0002' name='asp' /> <book id='0003' name='jsp' /></booklist><bookfav> <item name='xml' id='0001'/> <item name='asp' id='0002'/> <item name='jsp' id='0003'/></bookfav></root>"
set d= server.createobject("msxml2.domdocument")
d.loadXML s
set n = d.selectNodes("//book")
for each node in n
for i = 0 to node.attributes.length - 1
Response.write node.attributes(i).name & "=" & node.attributes(i).value & " "
next
Response.write "<p>"
next
这样可以输出信息
但是把s中的内容放入到一个XML中
set d= server.createobject("msxml2.domdocument")
d.load("test.xml")
set n = d.selectNodes("//book")
for each node in n
for i = 0 to node.attributes.length - 1
Response.write node.attributes(i).name & "=" & node.attributes(i).value & " "
next
Response.write "<p>"
next
这样就什么信息也没有了。
这是什么原因呢?
...全文
89 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hookee 2010-10-27
  • 打赏
  • 举报
回复
把xml文件的路径写全

<%
set d= createobject("msxml2.domdocument")
d.async = False
d.validateOnParse = False
d.preserveWhiteSpace = False
d.resolveExternals = False
d.load "c:\test.xml"
If d.parseError.errorCode <> 0 Then
Response.Write d.parseError.errorCode & "|" & d.parseError.srcText & "|" & d.parseError.reason
Response.End
set d = Nothing
End If

set n = d.selectNodes("//book")
for each node in n
for i = 0 to node.attributes.length - 1
Response.write node.attributes(i).name & "=" & node.attributes(i).value & " "
next
Response.write "<p>"
next
set d = Nothing
%>
Dogfish 2010-10-27
  • 打赏
  • 举报
回复
你那个文件的路径是否正确。还有,读写权限有没有?
wode421898419 2010-10-27
  • 打赏
  • 举报
回复
确实是路径问题,asp不象.net里面同一目录可以直接写文件名
加个server.MapPath就可以了

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧