PDA

View Full Version : Excel Recursive function through XML file



ArcadeNut
01-29-2016, 07:19 PM
I'm trying to create a list of all nodes from XML file. I created the functions below but when it calls the function within the loop, I get an "argument not optional" error.

Sub CreateList()
xmlExportDoc = "E:\Software Developement\SystemConfig.xml"

Dim xmldoc As MSXML2.DOMDocument
Dim xmlNodelist As MSXML2.IXMLDOMNodeList


Set xmldoc = New MSXML2.DOMDocument
xmldoc.async = False
xmldoc.Load (xmlExportDoc)
Set xmlNodelist = xmldoc.SelectNodes("/SystemConfig/Nodes/Node")
On Error Resume Next
ListNodes xmlNodelist
Set xmldoc = Nothing
Debug.Print "DONE!"
End Sub

Sub ListNodes(ByVal Nodes As MSXML2.IXMLDOMNodeList)
Dim xNode As MSXML2.IXMLDOMNode

For Each xNode In Nodes
Debug.Print xNode.Attributes(0).Text
If xNode.HasChildNodes Then

ListNodes (xNode.ChildNodes)
End If
Next xNode


End Sub

p45cal
01-30-2016, 09:41 AM
change:
ListNodes (xNode.ChildNodes)
to:
ListNodes xNode.ChildNodes