1
我怎样才能通过每一父节点的值从第一个开始到最后和应用:VBA开始在第一个节点,如果它存在 - 使用如果没有
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>
电流输出: “香蕉发现” “香蕉发现” “香蕉发现” “香蕉发现”
谢谢..这是一个漫长的夜晚:) – NRH