I am trying to achieve meaningful XML comparison. I want to compare two different XML to know if they are 'meaningful' equal.
Example XML 1:
<?xml version="1.0" encoding="UTF-8"?>
<al:moAttribute>
<al:name>impiId</al:name>
<al:value>616731935012345678</al:value>
</al:moAttribute>
<al:moAttribute>
<al:name>impuId</al:name>
<al:value>tel:+16167319350</al:value>
</al:moAttribute>
XML 2 :
<?xml version="1.0" encoding="UTF-8"?>
<al:moAttribute>
<al:name>impuId</al:name>
<al:value>tel:+16167319350</al:value>
</al:moAttribute>
<al:moAttribute>
<al:name>impiId</al:name>
<al:value>616731935012345678</al:value>
</al:moAttribute>
In this example both the XMLs are 'meaningful' equal but only differs in the sequence of elements. I want to compare both of them to know if they are almost equal.
I tried this solution :
Best way to compare 2 XML documents in Java
I tried :
XMLUnit.setIgnoreWhitespace(true);
diff.identical (...);
diff.similar (...);
But if the XML's differs in sequence, XML comparison returns false.
Any suggestions please ?