I am trying to parse a general XML file, via VBA. What I want to do with it: extract the values of the xml nodes, write them into a XML file and export it.
Do you know any library that actually lets me read one node at a time, for me to process with a understandable documentation, and some examples, even minimal ones.
So far:
Sub Go()
Dim xmlDoc As MSXML2.DOMDocument
Dim xmlElement As MSXML2.IXMLDOMElement
Dim xmlNode As MSXML2.IXMLDOMElement
Set xmlDoc = New MSXML2.DOMDocument
xmlDoc.Load ("E:\cdCatalog.xml")
Set xmlElement = xmlDoc.documentElement
Set xmlNode = xmlElement.FirstChild
parseNodes xmlElement, 1, 1
'parseNodes xmlNode, 1, 1
End Sub
Sub parseNodes(node As MSXML2.IXMLDOMElement, i As Integer, j As Integer)
Dim child As MSXML2.IXMLDOMNode
'result = node.baseName & " : " & node.Text
result = node.nodeName
Sheet1.Activate
' text if...
Cells(i, j) = result
j = j + 1
If (node.hasChildNodes) Then
For Each child In node.childNodes
i = i + 1
'MsgBox child.Text
MsgBox TypeName(node.childNodes)
parseNodes child, i, j
Next
End If
End Sub