【发布时间】:2015-03-31 20:29:02
【问题描述】:
以下代码适用于 XML 1,但不能从 XML 2 读取行(添加了 ROOT)。你知道为什么吗?
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.async="false"
xmlDoc.setProperty "SelectionLanguage", "XPath"
xmlDoc.load("test.xml")
set nodes=xmlDoc.SelectNodes("//customer")
for i=0 to nodes.length-1
set node = nodes(i)
set company = node.selectSingleNode("company")
msgbox company
next
XML 1:
<?xml version="1.0" encoding="UTF-8"?>
<customers>
<customer>
<name>ABCars</firma>
</customer>
</customers>
XML 2:
<?xml version="1.0" encoding="UTF-8"?>
<ROOT xmlns="http://www.something.com ">
<customers>
<customer>
<name>ABCars</firma>
</customer>
</customers>
</ROOT>
【问题讨论】: