I have an XML file and this XML file has namespaces declared
This worked for me (after some amount of head-scratching)
Sub Tester()
Const XML As String = "" & _
"" & _
" Testing " & _
" "
Dim xmlDom As New MSXML2.DOMDocument60
Dim nodeList As MSXML2.IXMLDOMNodeList
Dim iNode As MSXML2.IXMLDOMNode
With xmlDom
.async = False
.validateOnParse = True
.LoadXML XML
.setProperty "SelectionLanguage", "XPath"
'set the default namespace and give it a prefix (e.g.) "xx"
.setProperty "SelectionNamespaces", _
"xmlns:xx='urn:crystal-reports:schemas:report-detail'"
'use the same default prefix in your XPath
Set nodeList = .SelectNodes("//xx:Test")
End With
Debug.Print nodeList.Length
For Each iNode In nodeList
Debug.Print iNode.XML
Next iNode
End Sub