I need help figuring out how to properly parse through .xml files. Used them plenty just not in code. I'm looking to backup the 100 plus tables I have in excel with the option of importing back in on newer iterations of the workbook due to table structure changes. The .xml file will contain datasets of each table in a single .xml so I'm looking to identify the table name and then pull the records into an array. From there I've got no problems.
.xml example couldn't figure out how to keep formatting on my test .xml when posting it
Currently what I have that I've played with but getting stuck.
.xml example couldn't figure out how to keep formatting on my test .xml when posting it
Code:
Header
root open
notes
version
id
table open
table name
record open
field 1
field 2
field 3
field 4
record close
record open
field 1
field 2
field 3
field 4
record close
table close
table open
table name
record open
field 1
field 2
field 3
field 4
record close
record open
field 1
field 2
field 3
field 4
record close
table close
root close
Currently what I have that I've played with but getting stuck.
Code:
Dim xDoc As MSXML2.DOMDocument60
Dim xNode As MSXML2.IXMLDOMNode
Dim xRecords As MSXML2.IXMLDOMNodeList
Dim xElements As MSXML2.IXMLDOMNodeList
Set xDoc = New MSXML2.DOMDocument60
If xDoc.Load(ThisWorkbook.Path & "\backup.xml") Then
' The document loaded successfully.
Set xElements = xDoc.getElementsByTagName("Table")
' At this point I'm lost and just get errors or nothing on things I've tried
For Each xNode In xElements.Item(1).ChildNodes
Debug.Print xNode.Text
Next
Else
' The document failed to load.
MsgBox "error loading"
End If