【发布时间】:2011-05-31 19:34:49
【问题描述】:
我有一个 XML ResponseXML 对象。我想遍历所有名为“XYZ”的节点。我该怎么做?
【问题讨论】:
我有一个 XML ResponseXML 对象。我想遍历所有名为“XYZ”的节点。我该怎么做?
【问题讨论】:
以下是一些可用于解析您的 XML 的函数:
Private xml As MSXML.DOMDocument
Private Sub loadXMLFile(xmlFile)
Set xml = New DOMDocument
xml.async = False
xml.Load (xmlFile)
End Sub
Private Sub loadXMLString(xmlString)
Set xml = New DOMDocument
xml.LoadXml (xmlString)
End Sub
Public Function getNodeValue(xpath As String) As String
getNodeValue = xml.SelectSingleNode(strXPath).Text
End Function
Public Function getNodes(xpath as string) As IXMLDOMNodeList
Set getNodes = xml.SelectNodes(xpath)
End Function
Public Function getNode(xpath as string) As IXMLDOMNode
Set getNode = xml.SelectSingleNode(xpath)
End Function
有关 MSXML 的更多信息,请参阅 MSDN:http://msdn.microsoft.com/en-us/library/aa468547.aspx
【讨论】:
DOMDocument 是 DOMDocument30 的同义词(即 MXSML v3.0),并且任何更新的版本都必须具有在 DOMDocument60 中指定的完整版本(对于 MSXML v6 .0) - 见msdn.microsoft.com/en-us/library/ms757837%28VS.85%29.aspx 和blogs.msdn.com/b/xmlteam/archive/2006/10/23/…
【讨论】: