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:

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:

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.
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.
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.

Videos
Notepad++ download here should do exactly as you ask.
Quick guide here on using the compare/difference tool.
edit: Apologies, as matan129 stated you need to go to Language -> XML.
One solution is to 'split' the file manually before doing a normal diff (diff, kdiff, whatever) by applying
sed -i 's/>/>\n/g' file.xml
to manually insert newlines. Of course, the splitting can be improved to split at full tags, but this solution is a workaround as there seem to exist no standalone solutions.
One approach would be to first turn both XML files into Canonical XML, and compare the results using diff. For example, xmllint can be used to canonicalize XML.
$ xmllint --c14n one.xml > 1.xml
$ xmllint --c14n two.xml > 2.xml
$ diff 1.xml 2.xml
Or as a one-liner.
$ diff <(xmllint --c14n one.xml) <(xmllint --c14n two.xml)
Jukka's answer did not work for me, but it did point to Canonical XML. Neither --c14n nor --c14n11 sorted the attributes, but i did find the --exc-c14n switch did sort the attributes. --exc-c14n is not listed in the man page, but described on the command line as "W3C exclusive canonical format".
$ xmllint --exc-c14n one.xml > 1.xml
$ xmllint --exc-c14n two.xml > 2.xml
$ diff 1.xml 2.xml
$ xmllint | grep c14
--c14n : save in W3C canonical format v1.0 (with comments)
--c14n11 : save in W3C canonical format v1.1 (with comments)
--exc-c14n : save in W3C exclusive canonical format (with comments)
$ rpm -qf /usr/bin/xmllint
libxml2-2.7.6-14.el6.x86_64
libxml2-2.7.6-14.el6.i686
$ cat /etc/system-release
CentOS release 6.5 (Final)
Warning --exc-c14n strips out the xml header whereas the --c14n prepends the xml header if not there.
I had a similar problem and I eventually found: http://superuser.com/questions/79920/how-can-i-diff-two-xml-files
That post suggests doing a canonical XML sort then doing a diff. The following should work for you if you are on Linux, Mac, or if you have Windows with something like Cygwin installed:
$ xmllint --c14n FileA.xml > 1.xml
$ xmllint --c14n FileB.xml > 2.xml
$ diff 1.xml 2.xml
For what it's worth, I have created a java tool (or kotlin actually) for effecient and configurable canonicalization of xml files.
It will always:
- Sort nodes and attributes by name.
- Remove namespaces (yes - it could - hypothetically - be a problem).
- Prettyprint the result.
In addition you can tell it to:
- Remove a given list of node names - maybe you do not want to know that the value of a piece of metadata - say
<RequestReceivedTimestamp>has changed. - Sort a given list of collections in the context of the parent - maybe you do not care that the order of
<Contact>entries in<ListOfFavourites>has changed.
It uses XSLT and does all the above efficiently using chaining.
Limitations
It does support sorting nested lists - sorting innermost lists before outer. But it cannot reliably sort arbitrary levels of recursively nested lists.
If you have such needs you can - after having used this tool - compare the sorted byte arrays of the results. they will be equal if only list sorting issues remain.
Where to get it
You can get it here: XMLNormalize
Hello, is there a free tool for xml files comparison? I need to compare two files to check out is there any differences in the new one.