'root为根节点对象,即Bookstore
Set root = doc.GetRootElement
'用ChildElements方法获取子元素
Set children = root.ChildElements
'用ChildElementsByPath方法获取子元素,即3个Book元素
Set Xpathchildren = root.ChildElementsByPath("/Bookstore/*")
'这里看还没啥问题,貌似用ChildElements或ChildElementsByPath可以实现同样效果
For i = 1 to 3
msgbox "children: " & children.Item(i).ElementName
msgbox "Xpathchildren: " & Xpathchildren.Item(i).ElementName
Next
'用Xpathchildren的item找兄弟,3个Book元素互为兄弟应该
Set brother = Xpathchildren.Item(1).NextSibling
'这就诡异了,怎么brother为nothing呢-.-!难道用ChildElementsByPath获得的子元素用NextSibling方法就有问题?
If brother is nothing Then
msgbox "搞什么飞机啊!!!!"
End If
'用children的item找兄弟,就没啥问题
Set brother = children.Item(1).NextSibling