【发布时间】:2011-09-20 13:41:16
【问题描述】:
c.Value 是来自工作表第一行的单元格的文本(典型值为:名称、类型、重量、货币,但可以是任何值)。
filenames 是来自 Dir() 的循环,基本上是通过文件夹中的 XML 循环。
这些 xmls 可能具有最低级别的节点“权重”(例如),但在多个不同的父节点下。即这 3 个不同的 xpath: //Client/personal/weight 和 //Client/details/weight 和 //Client/details/info/weight。
我有这个代码:
Dim aDoc As DOMDocument
Dim aNode As IXMLDOMNode
Set aDoc = LoadXmlDoc(filenames(f))
Set aNodes = aDoc.getElementsByTagName(c.Value)
For f = 1 To UBound(filenames)
If aNodes.Length > 0 Then 'if at least one node is present
For Each aNode In aNodes 'loop thru each occurence of a node
c.Offset(f, 0).Value = aNode.Text & "parent is " & aNode.parentNode.parentNode
Next
End If
Nxt f
我要做的是为我在 c.value 中指定的子节点获取一个不同的 xpath 列表。
例如,
if c.value is weight
我正在尝试取回这个列表:
//Client/personal/weight
//Client/details/weight
//Client/details/info/weight.
http://msdn.microsoft.com/en-us/library/aa163921(office.10).aspx 是一个很好的参考,但我似乎无法找到如何从子节点获取 xpath。我刚刚设法获得了直接的父节点。
【问题讨论】: