You can achieve what you want with the help of a small Python script (you'll need Python installed, as well as the lxml toolkit).

tagsort.py:

#!/usr/bin/python

import sys
from lxml import etree

filename, tag = sys.argv[1:]

doc = etree.parse(filename, etree.XMLParser(remove_blank_text=True))
root = doc.getroot()
root[:] = sorted(root, key=lambda el: el.findtext(tag))
print etree.tostring(doc, pretty_print=True)

This script sorts the first-level elements under the XML document root by the content of a second-level element, sending the result to stdout. It's called like this:

$ python tagsort.py filename tag

Once you've got that, you can use process substitution to get a diff based on its output (I've added one element and changed another in your example files to show a non-empty result):

$ diff <(python tagsort.py file1 Id) <(python tagsort.py file2 Id)
4a5
>     <AddedTag>Something</AddedTag>
17c18
<     <Role>X</Role>
---
>     <Role>S</Role>
Answer from user27282 on Stack Exchange
๐ŸŒ
SemanticDiff
semanticdiff.com โ€บ online-diff โ€บ xml
SemanticDiff - Compare XML Online
Use our free online XML diff to perform a semantic comparison between two XML documents. Get a glimpse of what SemanticDiff can do. ... If the XML data is difficult to read (e.g. contains no line breaks), click the Prettify buttons
๐ŸŒ
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 - For the XML files, we used xsltproc with XSLT templates to sort the XML attributes, elements, and their child elements. Before comparing the sorted data with diff, we used xmllint to remove the white spaces and adjust the indentations.
๐ŸŒ
ExtendsClass
extendsclass.com โ€บ xml-diff.html
XML diff - Compare xml online
Copy and paste, drag and drop a XML file or directly type in the editors above, and then click on "Compare" button they will be compared if the two XML are valids. You can also click on "load XML from URL" button to load your XML data from a URL (Must be https).
๐ŸŒ
TextCompare
textcompare.org โ€บ xml
Online Xml Compare Tool
Find difference between 2 text files. Just input or paste original and modified text and click Compare button. Fast, Private & Unlimited.
Find elsewhere
๐ŸŒ
Altova
altova.com โ€บ xmlspy-xml-editor โ€บ compare-xml
Compare XML Files | Altova
It's easy to compare XML files with the XML diff tools in XMLSpy and DiffDog. Whether you need to compare two XML files or merge XML from three documents, these tools make it easy with XML-aware diff functionality.
๐ŸŒ
Xlcompare
xlcompare.com โ€บ compare-xml-files.html
Compare XML Files Online. Free. No Upload. Get the Semantic XML diffs.
October 3, 2009 - In our development process we are using XML trees in most cases. In XML Compare you can choose the best option for you. If text representation is more suitable for the data, you have โ€“ you can use it in the XML Compare.
๐ŸŒ
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.
๐ŸŒ
Minifier
minifier.org โ€บ xml-compare
XML Compare - Online XML Diff Checker
Green (Insert/Change): Data or content that has been added or differs in the second file. Precisely compares XML files without lowering execution. Processes complex XML structures and determines deviations in tags, attributes, and values. Easily visualize and compare two XML files in parallel.
๐ŸŒ
Oxygen XML
oxygenxml.com โ€บ doc โ€บ ug-oxygen โ€บ topics โ€บ file-comparison.html
Compare Files Tool
If you are comparing XML documents using the XML Fast or XML Accurate algorithms, you can enter an XPath 2.0 expression in the Ignore nodes by XPath text field to ignore certain nodes from the comparison. The resulting comparison will show you differences between the two files. The line numbers on each side and colored marks on the right-side vertical stripe help you to quickly identify the locations of the differences.
๐ŸŒ
Online Text Compare
onlinetextcompare.com โ€บ xml
Compare XML files online
This tool lets you compare the differences between two XML queries.
๐ŸŒ
Ybierling
ybierling.com โ€บ homepage โ€บ office productivity โ€บ how to compare two files in notepad++?
How to compare two files in Notepad++?
February 6, 2024 - Download Notepad++ 64 bit, an open source and free notepad, great XML file viewer ... Your two files will then be, after processing, displayed with their differences : lines deleted (-) and lines added (+).