怎么动态得到节点的属性集合?

hcsunjun 2003-12-02 04:41:24
如:
<root>
<record id='1' name='a'>
<a>aa</a>
</record>
<record id='2' name='b'>
<a>bb</a>
</record>
</root>
上述XML树,在每个节点上均有属性,但我现在怎么把这些属性全部读出来,注意,事先并不知道名字一定是id,name,我现在就要分别得到属性的名字及值,有办法吗?
...全文
33 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
ssm1226 2003-12-02
  • 打赏
  • 举报
回复
<%
set xmldoc=server.createObject("MSXML2.DOMDocument")
xmldoc.async=false
xmldoc.load server.mappath("csdn0001.xml")
set nodes=xmldoc.selectNodes("//record")
for each node in nodes
set attrs=node.attributes
for each attr in attrs
response.write "name:" & attr.nodeName & ";value:" & attr.text & "<br/>"
next
response.write "<hr>"
next
set attr=nothing
set attrs=nothing
set node=nothing
set nodes=nothing
set xmldoc=nothing
%>

8,906

社区成员

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

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