Have a look at File comparison tools, from which I am using WinMerge. It has an ability to compare XML documents (you may wish to enable DisplayXMLFiles prefilter for v2.14.0 or PrettifyXML for v2.16.x).

DisplayXMLFiles.dll - This plugin pretty-prints XML files nicely by inserting tabs and line breaks. This is useful for XML files that do not have line returns in convenient locations.

Note for v2.16.x

The plugin PrettifyXML is supplied with the software package. It can be activated as following:

  • Make sure that Plugins β†’ Plugin Settings β†’ Enable plugins is enabled.
  • Then use either File β†’ Recompare As β†’ Prettify XML or Plugins β†’ Scripts β†’ Prettify XML

For those who wish to play with deprecated DisplayXMLFiles, he needs to download e.g. winmerge-2.16.14-full-src.7z and copy Plugins\dlls\X64\DisplayXMLFiles.dll to WinMerge\MergePlugins\.

See also my feature comparison table.

Answer from dma_k on Stack Overflow
Top answer
1 of 11
36

Have a look at File comparison tools, from which I am using WinMerge. It has an ability to compare XML documents (you may wish to enable DisplayXMLFiles prefilter for v2.14.0 or PrettifyXML for v2.16.x).

DisplayXMLFiles.dll - This plugin pretty-prints XML files nicely by inserting tabs and line breaks. This is useful for XML files that do not have line returns in convenient locations.

Note for v2.16.x

The plugin PrettifyXML is supplied with the software package. It can be activated as following:

  • Make sure that Plugins β†’ Plugin Settings β†’ Enable plugins is enabled.
  • Then use either File β†’ Recompare As β†’ Prettify XML or Plugins β†’ Scripts β†’ Prettify XML

For those who wish to play with deprecated DisplayXMLFiles, he needs to download e.g. winmerge-2.16.14-full-src.7z and copy Plugins\dlls\X64\DisplayXMLFiles.dll to WinMerge\MergePlugins\.

See also my feature comparison table.

2 of 11
22

I wrote and released a Windows application that specifically solves the problem of comparing and merging XML files.

Project: Merge can perform two and three way comparisons and merges of any XML file (where two of the files are considered to be independent revisions of a common base file). You can instruct it to identify elements within the input files by attribute values, or the content of child elements, among other things.

It is fully controllable via the command line and can also generate text reports containing the differences between the files.

🌐
TextCompare
textcompare.org β€Ί xml
Online Xml Compare Tool
Copy the modified Xml in the right block. Just click Compare button to view side by side comparison. View the differences highlighted in colors. Privacy: This tool does all the processing on your browser, so nothing is saved on our server unless you choose to save.
🌐
SemanticDiff
semanticdiff.com β€Ί online-diff β€Ί xml
SemanticDiff - Compare XML Online
Compare two XML files in your browser using our free semantic diff tool. See how values and attributes differ while ignoring formatting changes.
🌐
GitHub
github.com β€Ί Shoobx β€Ί xmldiff
GitHub - Shoobx/xmldiff: A library and command line utility for diffing xml
XML type formats are also not only ... formats. A traditional diff on such a format would tell you line by line the differences, but this would not be be readable by a human. xmldiff provides tools to make human readable diffs in those situations....
Starred by 226 users
Forked by 53 users
Languages Β  Python 98.7% | Python 98.7%
🌐
SourceForge
diffxml.sourceforge.net
diffxml - XML Diff and Patch Utilities
diffxml & patchxml: Tools for comparing and patching XML files Β· The standard Unix tools diff and patch are used to find the differences between text files and to apply the differences. These tools operate on a line by line basis using well-studied methods for computing the longest common ...
🌐
ExtendsClass
extendsclass.com β€Ί xml-diff.html
XML diff - Compare xml online
This is the only proper xml diff checker. Most comparison tools are just line by line comparators, which is useless if the xml is formatted into a single line or if the data is not in order. A real xml comparison tool should compare randomly ordered data.
🌐
CoreFiling
corefiling.com β€Ί home β€Ί open source tools β€Ί xml comparison tool
Free Online XML Comparison Tool
June 20, 2025 - CoreFiling XML Differences uses XML Pretty Printer and diff to display differences between XML files in an easy-to-read format.
Find elsewhere
🌐
Oxygen XML
oxygenxml.com β€Ί xml_diff_and_merge.html
Oxygen Compare and Merge Tools
The complete XML diff and merge solution offers directory, file, 3-way, and XML fragment comparisons, six different algorithms, and multiple levels of comparison. In large teams composed either of developers or technical writers, the use of a shared repository is essential. It is common for numerous authors to be working on the same file simultaneously. In this case, finding what has been modified in your files and folders can often be difficult. To help you with this, Oxygen includes diff tools for comparing files and comparing directories.
🌐
PyPI
pypi.org β€Ί project β€Ί xmldiff
xmldiff Β· PyPI
XML type formats are also not only ... formats. A traditional diff on such a format would tell you line by line the differences, but this would not be be readable by a human. xmldiff provides tools to make human readable diffs in those situations....
      Β» pip install xmldiff
    
Published Β  May 13, 2024
Version Β  2.7.0
Top answer
1 of 6
9

Technically, XMLs are different

  • if they have whitespaces or not
  • if the order is different
  • if they have comments or not
  • if they have processing instructions or not
  • if their encoding is different
  • if their namespaces are different

but of course you can decide to ignore that or not, based on the semantic information an XML does not have.

Microsoft has developed the XML Diff and Patch tool for this purpose and you can integrate it in your own applications.

Note: the tool installs as "SQLXML Bulkload in .NET Code Sample" and comes with a Visual Studio solution XmlDiffView.sln that you need to compile yourself. Some basic programming knowledge in C# and Visual Studio Community Edition should be ok.

However, as mentioned in one of the answers on Stack Overflow, it has been compiled and made available on Bitbucket.

After that it comes with a UI that let's you choose the various XML comparison options:

When I apply it to the 2 XMLs of your questions, it throws an exception. That is because of the namespaces which are not defined. After removing the namespaces, it says:

2 of 6
6

Focusing on the part that moved sections should be reported as no difference made me think of https://semanticmerge.com/, which doesn't compare XML-files, but C# and C code. And as it understand those languages it is able to display if code has moved and not changed.

This leads to an alternative approach for this question: Could it be possible to translate the XML into C# classes, and then do a semantic merge on the resulting code?

One possible approach, if this tool is not written already, could be to translate each and every element to classes, and each attribute (and body texts) to a string property within that class. If you want to ignore namespaces, then let your translator remove them in the translation process.

I translated the XML example given as proof of concept and got the following:

class soapenv__Body {
  class mes__GetItem {
    class mes__ItemShape {
      class typ__BaseShape {
          string body="IdOnly";
      }
      class typ__BodyType {
          string body="Textus";
      }
      class typ__AdditionalProperties {
        class typ__FieldURI  {
            string FieldURI="item:Subject";
        }
        class typ__FieldURI  {
            string FieldURI="item:Categories"; 
        }
      }
    }
    class mes__ItemIds {
      class typ__ItemId {
          string Id="AAMYAAA=";
      }
    }
  }
}

Then I switched the mes:ItemIds and mes:ItemShape and changed the text to Textus. Compared the following two files in Semantic Merge and got the following image:

In this image one can see the move, indicated by the M icon, and the change in text indicated by the C icon. Lines indicates where the different parts have moved/changed, and it possible to actually see the differences if they exist.

Note that Semantic Merge even though understanding C# code, isn't to strict on the identical class names of typ__FieldURI, which could be a nice features as XML can contain multiple nodes with the same name.

Summa summarum: Semantic Merge can correctly identify the XML as identical (or not) even though elements move, if you can convert the XML into a C# class structure.

🌐
Altova
altova.com β€Ί xmlspy-xml-editor β€Ί compare-xml
Compare XML Files | Altova
The XMLSpy XML Editor includes a visual XML diff tool that allows developers to easily compare and merge XML documents and directories in an intelligent, XML-aware manner.
🌐
Stylus Studio
stylusstudio.com β€Ί xml-diff.html
XML Diff Tool
Stylus Studio includes a built-in XML Differencing Tool that enables you to quickly and easily visualize differences in XML files and folders. Choose from split and merged text and tree views, filter for whitespace, namespaces, and more!
🌐
Xlcompare
xlcompare.com β€Ί compare-xml-files.html
Compare XML Files Online. Free. No Upload. Get the Semantic XML diffs.
October 3, 2009 - With its comprehensive comparison capabilities, XML Compare streamlines the process of identifying differences and integrating updates, thus enhancing productivity and collaboration among development teams.
🌐
Minifier
minifier.org β€Ί xml-compare
XML Compare - Online XML Diff Checker
... It shows missing properties, unequal values, and discrepancies in structure, tags, or attributes. ... The tool identifies and highlights XML differences in both structure and content during XML comparison.
🌐
Diffchecker
diffchecker.com
Compare text and find differences online or offline - Diffchecker
Compare text, files, and code (e.g. json, xml) to find differences with Diffchecker online for free! Use our desktop app for private, offline diffs.
🌐
Online Text Compare
onlinetextcompare.com β€Ί xml
Compare XML files online
This tool lets you compare the differences between two XML queries.
🌐
WaytoLearnX
tools.waytolearnx.com β€Ί en β€Ί xml-diff
XML Diff - XML Compare - Online tools
XML Diff, short for XML Difference, is a tool used to compare two XML (eXtensible Markup Language) documents and identify the differences or changes between them.
🌐
JSoftwareLabs
jsoftwarelabs.com β€Ί compare-diff-online β€Ί xml-comparison
Compare xml online - XML diff tool
Best online XML diff and compare tool with ignoring order of elements and namespaces capability. Supports large files and different xml objects and code compare