1

I have 4 XML files: A, B, C, and D. I want to know if the difference between A and B is the same as the difference between C and D.

My first thought was to use Microsoft's XML Diff Patch library, which compares two files and generates a DiffGram, which is an XML document that describes the difference between the two files being compared. My thought is that I could compare A to B to get DiffGram X and C to D to get DiffGram Y, and then do a third XML comparison between X and Y.

The idea sounds good on paper; unfortunately it's not turning out to be so simple. The difference between A and B is very similar to the difference between C and D, but X and Y look nothing like each other.

The problem is it gives DiffGrams like the following:

<xd:node match="4">
           <xd:node match="2">
              <xd:node match="1">
                 <xd:remove match="1-3" />
              </xd:node>
           </xd:node>

           <xd:node match="1">
              <xd:node match="1">
                 <xd:remove match="1-3" />
              </xd:node>
           </xd:node>
        </xd:node>

This has two major problems: first, it's extremely cryptic - I'd prefer it if it was more human-readable, but it's not the end of the world if that's not the case (since my primary purpose is programmatic processing). Secondly (and much more critically), it seems like that's very tightly coupled to the specific XML files that are in that particular comparison.

Does anyone know of a .NET library (preferably available as a NuGet package) that would be more suitable for that purpose?

1
+50

It may not be an exact match, but Altova can export the actual differences between two files: https://www.altova.com/diffdog/differences-report-files.html

You could then take the two differences and diff those.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.