Is there an open source command-line tool (for Linux) to diff XML files which ignores the element order?
Example input file a.xml
:
From your example, it looks like you only care about re-ordering elements within elements, but not reordering elements themselves. If so, then (as a previous respondent said) you need to use sort, but on the elements, not the elements nor the attributes.
Many would find it confusing to have XML elements named "tag" and/or "attr", since those are terms with specific meanings already in XML -- possibly that contributed to trying to sort by "@*" instead of sorting elements?
If your structure is really just like your example, a much more "XML-ish" representation would be:
Much more compact, avoids the terminology conflict, and makes the attributes be order-independent by definition -- which means any off-the-shelf XML diff utility will get the effect it seems you want, or you could just convert to canonical XML and use regular diff.