I'm trying to speed up a VB6 XML parser. The XML files to be parsed are stored on my local hard drive. The If xDOC.Load(objFile.Path) Then statement below is taking a very long time, according to my profiling results. That statement took 34.5 seconds overall during processing of a small batch of 100 XML files. A sample XML file is here. Can this code be improved to speed up XML file loading, or is the loading speed constrained by the nature of the XML files themselves?
Option Explicit
Dim objFSO As Object
Dim objFolder As Object
Dim objFile As Object
Dim xDOC As MSXML2.DOMDocument
Dim xPE As MSXML2.IXMLDOMParseError
Sub Main()
Set xDOC = New DOMDocument
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder("C:\My XML File Folder")
For Each objFile In objFolder.Files
Set xDOC = New DOMDocument
xDOC.async = False
If xDOC.Load(objFile.Path) Then
' process the file
Else
' XML file failed to load; log error and continue with next file
End If
Set xDOC = Nothing
Next objFile
Set objFolder = Nothing
End Sub