I'm new to vb6 and have to parse an xml document with a different depth of the tags like to following example:
<start>
<b>text1</b>
<c>
<c1>
<d>text</d>
</c1>
</c>
</start>
I'm using MSXML and trying to solve this problem recursive. My code is:
Sub1()
Set objXML = CreateObject("Msxml.DOMDocument")
objXML.async = True
objXML.Load "text.xml"
Dim nodeList As IXMLDOMNodeList
Dim node As IXMLDOMNode
Set nodeList = objXML.selectNodes("*")
For Each node In nodeList
print node.nodeName ' this works'
printNode (node) 'here is the problem explained below'
Next node
End Sub
Sub printNode(node As IXMLDOMNode)
Dim xmlNode As IXMLDOMNode
If node.hasChildNodes Then
For Each xmlNode In node.childNodes
printNode (xmlNode)
Next xmlNode
Print node.nodeName
End If
End Sub
The problem is that it isn't possible to call the sub printNode with the parameter node of the type IXmlDomNode. When I try to run the program I always get a runtimeerror 438 which says object doesn't support this function
The node does exist, I have tested this and can print the name and value of the node.
Can anyone explain my why and give me a hint how/solution how I can solve this problem?
You have a syntax error in your code. If you are calling a Sub you either do so without enclosing the parameters in parenthesis, or you use the Call Keyword in front of the Sub name.