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
🌐
Readthedocs
xmldiff.readthedocs.io › en › stable › commandline.html
Command-line Usage — xmldiff documentation
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 ...
🌐
GitHub
github.com › Shoobx › xmldiff
GitHub - Shoobx/xmldiff: A library and command line utility for diffing xml
xmldiff is a library and a command-line utility for making diffs out of XML. This may seem like something that doesn't need a dedicated utility, but change detection in hierarchical data is very different from change detection in flat data.
Starred by 226 users
Forked by 53 users
Languages   Python 98.7% | Python 98.7%
🌐
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
🌐
Go Packages
pkg.go.dev › github.com › pschlump › xml-diff
xml-diff command - github.com/pschlump/xml-diff - Go Packages
xml-diff will sort the attributes and values and then perform a diff on the results. ... The command line utility is in the top level directory.
🌐
PyPI
pypi.org › project › xmldiff
xmldiff · PyPI
... xmldiff is still under rapid development, and no guarantees are done that the output of one version will be the same as the output of any previous version. xmldiff is both a command-line tool and a Python library.
      » pip install xmldiff
    
Published   May 13, 2024
Version   2.7.0
🌐
O'Reilly
oreilly.com › library › view › xml-hacks › 0596007116 › ch02s20.html
29. What’s the Diff? Diff XML Documents - XML Hacks [Book]
There are online tools—one from DecisionSoft (http://www.decisionsoft.com) and another from DeltaXML (http://www.deltaxml.com)—that can help you quickly compare XML files to see how different they are. There are also several command-line tools available, such as IBM’s XML Diff and Merge Tool (http://www.alphaworks.ibm.com/tech/xmldiffmerge).
🌐
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 ...
Find elsewhere
🌐
GitHub
github.com › pschlump › xml-diff
GitHub - pschlump/xml-diff: Compare XML files after sorting attributes and fields · GitHub
xml-diff will sort the attributes and values and then perform a diff on the results. ... The command line utility is in the top level directory.
Author   pschlump
🌐
GitHub
github.com › joh › xmldiffs
GitHub - joh/xmldiffs: Compare two XML files, ignoring element and attribute order.
For unified and context diffs, the value defaults to 3. For html diff, the value defaults to None, which produces full output lines. Pass an integer to produce context lines. -o, --output - Name of the output file. Default value is minus sign, which prints the diff to the stdout. -x, --xml - instead of comparing two xml files, write sorted contents of FILE1 to FILE2.
Starred by 96 users
Forked by 27 users
Languages   Python 100.0% | Python 100.0%
🌐
Lprp
lprp.fr › libxmldiff
libxmldiff | LPRP.fr
April 3, 2021 - The xmldiff example allow to use all the power of libxmldiff from command line : xmldiff v0.2.9 - (c) 2004 - Remi Peyronnet - http://people.via.ecp.fr/~remi/ xmldiff - diff two XML files.
🌐
Read the Docs
media.readthedocs.org › pdf › xmldiff › latest › xmldiff.pdf pdf
xmldiff Documentation Lennart Regebro May 21, 2023
To use it from the command-line, just run xmldiff ... 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 ...
🌐
SmartBear
smartbear.com › blog › how-to-compare-xml-files-using-diffxml
How to Compare XML Files Using Diffxml
Open a command line window and cd to your diffxml directory. Type diffxml.bat and press Enter to diff the demonstration files. If you don’t see an error then the output from diffxml should be in out1.xml.
🌐
Oxygen XML
oxygenxml.com › home › board index › oxygen xml editor/author/developer › feature request
Commandline or library diff tool - Oxygen XML Forum
While the world is full of XML diff tools, few can out-do Oxygen's diff xml tool. Have you considered making the diff tool a command-line utility or a Java package that only does diffing, no display. That is, a tool that takes in two input files and an output file, and possibility to define ...
🌐
Readthedocs
xmldiff.readthedocs.io
xmldiff — xmldiff documentation
xmldiff is a library and a command-line utility for making diffs out of XML. This may seem like something that doesn’t need a dedicated utility, but change detection in hierarchical data is very different from change detection in flat data. XML type formats are also not only used for computer ...
🌐
Microsoft Learn
learn.microsoft.com › en-us › archive › blogs › dmahugh › open-xml-diff-tools
Open XML diff tools | Microsoft Learn
In those situations, a diff utility can save a lot of time. I'll cover two good options for comparing Open XML documents below: Eric White's free command-line tool OpenXmlDiff, which comes with source code and can be useful in automated workflows, and Altova's commercial GUI tool DiffDog, which offers a variety of interactive capabilities for analyzing the differences between Open XML documents.
🌐
O'Reilly
oreilly.com › library › view › windows-developer-power › 0596527543 › ch19s07.html
19.6 Comparing and Unit Testing XML with XML Diff and Patch - Windows Developer Power Tools [Book]
Using Microsoft’s XML Diff and Patch, you can compare XML documents to determine whether they are equivalent and, if not, produce a diffgram describing the differences. This diffgram can then be used to patch one XML file to make it identical to the other. ... The included samples are the source for the command-line utilities and a sample to create an HTML representation of the difference between two XML documents.
🌐
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 diff command essentially printed both files as differences, even though the content is the same but located on different lines. Therefore, let’s sort the book elements first with the XSLT templates using the xsltproc command: $ xsltproc -o a-sorted.xml bookstore.xslt a.xml $ xsltproc -o b-sorted.xml bookstore.xslt b.xml $ cat a-sorted.xml <?xml version="1.0"?> <bookstore><book category="CHILDREN" format="PAPERBACK"> ...