用asp读xml文件问题

Hunter 2009-03-03 03:41:03
xml文件格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<userinfo>
<remainFee>60000</remainFee>
<Channels>
<Channel><id>11</id><name>上海电信</name><MsgCount>70</MsgCount></Channel>
<Channel><id>28</id><name>联通通道</name><MsgCount>70</MsgCount></Channel>
<Channel><id>11</id><name>上海电信</name><MsgCount>70</MsgCount></Channel>
</Channels>
</userinfo>

想要把<remainFee>60000</remainFee>里面的60000读取出来,请高手们帮忙。

本人在网上找了很多读取xml的方法试了都不行。网上的都是规则的XML格式可以读取,换上面的格式就不行了。

xml的编码是UTF-8.
注意<userinfo></userinfo>里面有两层数据。

急!!!!在线等


...全文
110 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhuyongzhao 2009-03-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 xiaofanku 的回复:]
<%
Dim strTemp
strPath=Server.MapPath("../host.xml")
set parser=Server.CreateObject("Microsoft.XMLDOM")
parser.Load(strPath)
if parser.parseError.errorCode <>0 then
Response.write "error"
end if
set itemnode=parser.documentElement
If itemnode.hasChildNodes then
strTemp=itemnode.childNodes.item(0).firstChild.nodeValue
Else
strTemp="lost"
End If
Response.Write strTemp
%>
[/Quote]

正解
街头小贩 2009-03-03
  • 打赏
  • 举报
回复
只要你的XML是合法的!
街头小贩 2009-03-03
  • 打赏
  • 举报
回复
<%
Dim strTemp
strPath=Server.MapPath("../host.xml")
set parser=Server.CreateObject("Microsoft.XMLDOM")
parser.Load(strPath)
if parser.parseError.errorCode<>0 then
Response.write "error"
end if
set itemnode=parser.documentElement
If itemnode.hasChildNodes then
strTemp=itemnode.childNodes.item(0).firstChild.nodeValue
Else
strTemp="lost"
End If
Response.Write strTemp
%>

8,909

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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