I'm using VBA in Excel 2003 to isolate some xml nodes. Everything is peachy until the 'contains' method is called in an xpath wildcard search where the 'unknown method' error is returned.
The code to load the xml file is:
Public Function LoadXml()
strPath = ThisWorkbook.Path & "\V1.xdp"
Set docXml = New MSXML2.DOMDocument
docXml.Load (strPath)
Set LoadXml = docXml
End Function
The code to isolate the node is:
Public Sub TestXpath()
Dim docXml As MSXML2.DOMDocument
Dim NodeList As IXMLDOMSelection
Dim CurrNode As IXMLDOMNode
Dim n As Long
'Identify xpath
Dim strXPath As String
strXPath = "//event/script[contains (text(),'validationScript.errorCount')]"
'Loop through nodes and inspect attributes to ensure we've specified the correct XPath
Set docXml = LoadXml
Set NodeList = docXml.SelectNodes(strXPath)
For n = 0 To (NodeList.Length - 1)
Set CurrNode = NodeList.Item(n)
InspectNode CurrNode
Next
ExitSub:
Set docXml = Nothing
Exit Sub
End Sub
I've got a reference set to MSXML v6. Any idea why I'm getting the 'unknown method' error?
Thanks
Jon