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)
Answer from Jukka Matilainen on Stack Exchange
🌐
GitHub
github.com › Shoobx › xmldiff
GitHub - Shoobx/xmldiff: A library and command line utility for diffing xml
There is also a method diff_trees() that take two lxml trees, and a method diff_texts() that will take strings containing XML.
Starred by 226 users
Forked by 53 users
Languages   Python 98.7% | Python 98.7%
🌐
Readthedocs
xmldiff.readthedocs.io › en › stable › commandline.html
Command-line Usage — xmldiff documentation - Read the Docs
To use it from the command-line, just run xmldiff with two input files: ... There are a few extra options to modify the output, but be aware that not all of the combinations are meaningful, so don’t be surprised of you add one and nothing happens. You can select different output formats with xmldiff, but beware that some formatters may assume certain things about the type of XML.
🌐
Ubuntu
manpages.ubuntu.com › manpages › jammy › man1 › xmldiff.1.html
Ubuntu Manpage: xmldiff - Create a diff for two XML files
Common usage: $ xmldiff file1.xml file2.xml Making an output a bit more human readable by structuring it with whitespace: $ xmldiff -f xml -p file1.xml file2.xml
🌐
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 ...
🌐
Ubuntu
manpages.ubuntu.com › manpages › bionic › man1 › xmldiff.1.html
Ubuntu Manpage: xmldiff - Tree 2 tree correction between xml documents
xmldiff is a utility for extracting differences between two xml files. It returns a set of primitives to apply on source tree to obtain the destination tree.
🌐
Medium
medium.com › @nirbhaysingh281 › comparing-two-files-in-linux-a728e45f0fbc
Comparing two files in Linux. Comparing two XML files in Linux can be… | by Nirbhay Singh | Medium
January 9, 2024 - xmldiff is a specialized tool for comparing XML files. You may need to install it first. On Debian-based systems, you can use: ... This opens the files in Vim with a side-by-side diff view.
Find elsewhere
🌐
PyPI
pypi.org › project › xmldiff
xmldiff · PyPI
Added a simple xmlpatch command and API. ... Changed the substitution unicode character area to use the Private Use Area in BMP(0), to support narrow Python builds · Added –unique-attributes argument. Added options for faster node comparisons. The “middle” option is now default, it had very few changes in matches, but is much faster. Implemented a Fast Match algorithm for even faster diffing.
      » pip install xmldiff
    
Published   May 13, 2024
Version   2.7.0
🌐
Lprp
lprp.fr › libxmldiff
libxmldiff | LPRP.fr
April 3, 2021 - --before-values yes : Add before values in attributes or text nodes --sep | : Use this as the separator --encoding none : Force encoding --tag-childs yes : Tag Added or Removed childs --merge-ns yes : Create missing namespace on top of document --special-nodes-ids yes : Content of special nodes (CData, PI,...) will be used as ids --special-nodes-before-value no : Display changed value for special nodes (CData, PI,...) --diff-ns http://... : Namespace definition, use no to disable --diff-xmlns diff : Alias to use, use no to disable --diff-attr status : Name of attribute to use (should not be used in docs) </output.xml></input.xml>
🌐
SysTutorials
systutorials.com › docs › linux › man › 1-hwloc-diff
hwloc-diff: Compute differences between two XML topologies - Linux Manuals (1)
hwloc-diff computes the difference between two XML topologies and stores the result into <output.xml> if any, or dumps it to stdout otherwise. The
🌐
GitHub
github.com › pschlump › xml-diff
GitHub - pschlump/xml-diff: Compare XML files after sorting attributes and fields · GitHub
Compare XML files after sorting attributes and fields - pschlump/xml-diff
Author   pschlump
🌐
Baeldung
baeldung.com › home › files › how to compare two files with the same content but on different lines
How to Compare Two Files With the Same Content but on Different Lines | Baeldung on Linux
December 12, 2023 - The first one is where we copy the whole XML data (<xsl:template match=”@*|node()”>) and sort the attributes and child elements by name. The second one is where we create a rule for sorting the book elements by the author element value (<xsl:template match=”bookstore”>). If we compare the first and the second files using diff as-is, it shows the differences even though both files have the same content:
🌐
Linux.com
linux.com › home › news › xmldiff patches xml files by sending just the changes
xmldiff patches XML files by sending just the changes - Linux.com
June 5, 2008 - Author: Ben Martin The GNU diff and patch utilities let you compare files to generate a patch that describes the changes between files. You can then apply the patch file on that machine or another. You might think to use diff and patch on XML files, since they are just text files — and depending ...
🌐
SmartBear
smartbear.com › blog › how-to-compare-xml-files-using-diffxml
How to Compare XML Files Using Diffxml
Diffxml is a Java command-line tool setup to run on Linux/Unix and it’s not obvious how to use it on Windows. There are many programs like this that are designed for Linux but run …
🌐
UW Computer Sciences
pages.cs.wisc.edu › ~yuanwang › xdiff.html
X-Diff: An XML Diff Tool
C++ version (on Unix/Linux): Xerces C++ v1.4.0 · Installation, Compiling, and Running · Please read the README file in the package. X-Diff: An Effective Change Detection Algorithm for XML Documents. Yuan Wang, David J. DeWitt, Jin-Yi Cai.
🌐
Cloudzenia
cloudzenia.com › tools › xml-diff
Understanding XML Diff Tool: A Complete Guide to XML Comparison
Meld is a well-liked option for Linux users since it facilitates version control integration and enables side-by-side XML file comparison. Its simple interface facilitates difference analysis.
🌐
Unix.com
unix.com › shell programming and scripting
How to do find differences between 2 XML Files? - Shell Programming and Scripting - Unix Linux Community
September 8, 2014 - Hello All, Requirement is to compare 2 XML files and see if there are any differences but from some of the providers We are receiving UTF-16 formatted XML file with no end of line as shown below. Excerpt of data file: …