无法阅读某些格式的XML节点,这些格式正在推动我和我的合作伙伴疯狂......
我们已经尝试了这个..但我们不断获得“空白”msgboxs ..任何帮助都会非常感激
Set xmlObject = CreateObject("Msxml2.DOMDocument.6.0")
urlPath = "C:\Users\...\Desktop\LolChampsSelect.xml"
xmlObject.async = False
xmlObject.load urlPath
'set ban = xmlObject.selectNodes("//*")
set ban = xmlObject.selectNodes("//*")
set ban = xmlObject.selectNodes("//red/ban[@order]
msgbox ban(0).text
XML文件
<championSelect>
<blue>
<ban order="1" name="Darius"/>
<ban order="3" name="Elise" />
<ban order="5" name="Twisted Fate" />
<pick order="1" name="Gragas" />
<pick order="4" name="Shen" />
<pick order="5" name="Shyvanna" />
答案 0 :(得分:2)
处理属性的最小演示代码:
Dim sXml : sXml = Join(Array(_
"<championSelect>" _
, " <blue>" _
, " <ban order=""1"" name=""Darius""/>" _
, " <ban order=""3"" name=""Elise"" />" _
, " </blue>" _
, "</championSelect>" _
), vbCrLf)
Dim objMSXML : Set objMSXML = CreateObject("Msxml2.DOMDocument")
objMSXML.setProperty "SelectionLanguage", "XPath"
objMSXML.async = False
objMSXML.loadXml sXml
If 0 = objMSXML.parseError Then
Dim ndFound : Set ndFound = objMSXML.SelectSingleNode("/championSelect/blue/ban[@order=""3""]")
WScript.Echo ndFound.tagName, "found"
WScript.Echo "name:", ndFound.getAttribute("name")
Else
WScript.Echo objMSXML.parseError.reason
End If
输出:
==============
ban found
name: Elise
==============
使用它来查找文档中的对象/函数/属性。