Has anyone had problems with this function ?
I get a error 91 on the With node.ChildNodes line when I use it with a DOMDocument4.0, but if I go back to using a DOMDocument3.0 it works fine?
Option Explicit
Private Sub Command1_Click()
Dim xmlDoc As New MSXML2.DOMDocument30
‘Dim xmlDoc As New MSXML2.DOMDocument40
xmlDoc.async = False
‘xmlDoc.setProperty “SelectionLanguage”, “XPath”
xmlDoc.Load (App.Path & “nlis.xml”)
If xmlDoc.parsed = True Then
Debug.Print “Loaded ” & App.Path & “nlis.xml”
Else
Debug.Print “Error ” & xmlDoc.parseError.reason
End If
If GetTestValues(xmlDoc) Then
Debug.Print “got values”
Else
Debug.Print “problem”
End If
Set xmlDoc = Nothing
End Sub
‘Public Function GetTestValues(pxmlReceive As MSXML2.DOMDocument40) As Boolean
‘Dim mpxmlReceive As MSXML2.DOMDocument40
Public Function GetTestValues(pxmlReceive As MSXML2.DOMDocument30) As Boolean
Dim mpxmlReceive As MSXML2.DOMDocument30
Dim node As MSXML2.IXMLDOMNode
Dim node2 As MSXML2.IXMLDOMNode
Set mpxmlReceive = pxmlReceive
Debug.Print “Start loop ”
Set node = mpxmlReceive.selectSingleNode(“//ROAD_SEARCH_ENTRY”)
With node.childNodes
.Reset
Set node2 = .nextNode
Do While Not node2 Is Nothing
Select Case node2.baseName
Case “OTHER_USRN”
Debug.Print “usrn ” & node2.Text
Case “OTHER_ROADS_AND_FOOTWAYS”
‘
Case “ADDITIONAL_QUESTION”
‘
Case Else
‘
End Select
Set node2 = .nextNode
If node2 Is Nothing Then
GoTo PROCEXIT
End If
Loop
End With
PROCEXIT:
Debug.Print “Finished”
GetTestValues = True
End Function