I've downloaded several large XML files (about 40 M each), each year is treated separate in the the files i.e. each node in the XML files has the structure of:

rest of xml follows

The files change infrequently, (maybe twice a year). I need to statistically analyse the files. Should I combine the files into one large file (about 500 MB) or simply loop over each year?
Is below the best way to join the files and what am I doing wrong that it is not saving the file?


Sub JoinXML()
Const mPath As String = "C:\tmp\data_"

Dim XDoc As MSXML2.DOMDocument60, XCombined As MSXML2.DOMDocument60
Dim Level1 As MSXML2.IXMLDOMNode, RootElement As MSXML2.IXMLDOMNode
Dim yr As Long

    Set XCombined = New MSXML2.DOMDocument60        'the new file
    Set RootElement = XCombined.createElement("data")    ' the root
    Set XDoc = New MSXML2.DOMDocument60             'the existing year
    For yr = 1999 To 2013
        XDoc.async = False
        XDoc.validateOnParse = False
        XDoc.Load (mPath & yr & ".xml")
        For Each Level1 In XDoc.DocumentElement.ChildNodes
            If Level1.NodeType = NODE_ELEMENT Then Call RootElement.appendChild(Level1)
        Next Level1
    Next yr
    XCombined.Save (mPath & ".xml")
    Application.StatusBar = " "
    Set XDoc = Nothing
    Set XCombined = Nothing

End Sub