前端之家收集整理的这篇文章主要介绍了
[AHK]用xmlpath方式解析xml的值,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
xmldata = ; replace with fileread as you already have done
(join`r`n
<?xml version="1.0"?>
<root>
<itemLookup>
<version>1.0</version>
<typeID>37</typeID>
<typeName>Isogen</typeName>
</itemLookup>
<itemLookup>
<version>2.0</version>
<typeID>33</typeID>
<typeName>Isogen</typeName>
</itemLookup>
</root>
)
doc := ComObjCreate("MSXML2.DOMDocument.6.0")
doc.async := false
doc.loadXML(xmldata)
;取第一个itemLookup的typeID
DocNode := doc.selectSingleNode("//itemLookup/typeID")
DocText := DocNode.text
MsgBox %DocText%
;取符合某个条件的itemLookup的typeID
DocNode := doc.selectSingleNode("//itemLookup[version=""2.0""]/typeID")
DocText := DocNode.text
MsgBox %DocText%
;遍历itemLookup
nodes:=doc.selectSingleNode("/root").childNodes
for node in nodes
{
DocText := node.text
MsgBox %DocText%
}