【发布时间】:2015-06-26 10:34:01
【问题描述】:
如何从第一个到最后一个递增每个父节点并应用:
For Each n In XMLFile.SelectNodes("/catalog/book")
If XMLFile.SelectSingleNode("/catalog/book/banana") Is Nothing Then
MsgBox ("banana not here")
Else
MsgBox ("banana found")
End If
Next
香蕉在第一本书中不存在:
?xml version="1.0"?>
<catalog>
<book id="Adventure">
<author>Ralls, Kim</author>
<title>XML Developer's Guide</title>
<price>44.95</price>
</book>
<book id="Adventure">
<author>Ralls, Kim</author>
<title>Midnight Rain</title>
<price>5.95</price>
<banana>ring</banana>
</book>
<book id="Adventure">
<author>Ralls, Kim</author>
<title>Mist</title>
<price>15.95</price>
<banana>ring</banana>
</book>
<book id="Mystery">
<author>Ralls, Kim</author>
<title>Some Mystery Book</title>
<price>9.95</price>
<banana>ring</banana>
</book>
</catalog>
电流输出: “发现香蕉” “发现香蕉” “发现香蕉” “发现香蕉”
【问题讨论】:
标签: xml vba dom xml-parsing