Hi all,

I am currently working on a macro that will allow me to compare 2 XML files in VBA. I am using the MSXML library so that I can use XML objects in code.
So far I have been able to load 2 XML files, but I have not been able to figure out how to loop through the nodes and child nodes in order to compare them.

The code I am using so far to load the XML files and attempt to loop through them is this:

    Dim XML1 As New MSXML2.DOMDocument60
    Dim XML2 As New MSXML2.DOMDocument60
    With XML1
        .validateOnParse = True
        .setProperty "SelectionLanguage", "XPath"   ' necessary in version 3.0, possibly redundant here
        .async = False
    End With
    With XML2
        .validateOnParse = True
        .setProperty "SelectionLanguage", "XPath"   ' necessary in version 3.0, possibly redundant here
        .async = False
    End With

    XML1.Load (File1.Path)  'FSO file object
    XML2.Load (File2.Path)  'FSO file object

    Dim XmlNodes As IXMLDOMNodeList
    Dim XmlNode  As IXMLDOMNode

    Set XmlNodes = XML1.SelectNodes("//*/*")  '<- This selection is a guess.  Examples always point to specific nodes by name, which won't work for my project.

    For Each XmlNode In XmlNodes
        'This is where I am stuck
    Next XmlNode
I have never worked with the MSXML library before, so I am not sure how to read nodes and their attributes correctly. I have tried a few methods I have found on Google, but have had no success. Most examples will read specific items in XML files such as peoples names or book titles which look for specific nodes. My one needs to read an entre XML file so needs to capture all nodes (Basically *). Once I can understand how to read nodes and their attributes I can get it working. My approach will be a slow and methodical process of looping through the nodes in XML1 and its child nodes, and then comparing those to the nodes/child nodes of XML2. It will be inefficient, but will be a start.

If anyone out there has experience with XML files I would appreciate any advice. Once I get the macro working I will share my code to help others.