The part of XMLUnit which decides which node to compare to which other node is controlled by the ElementQualifier. In your case it should work if you just used the ElementNameQualifier to make sure XMLUnit will compare the sub-trees with the same root names.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm trying to compare two xml documents using xmlunit 1.3.
The first is :
<a>
<b>
<c>text</c>
<d>text</d>
</b>
<e>
<f>text</f>
<g>text</g>
</e>
</a>
and
<a>
<e>
<g>text</g>
<f>text</f>
</e>
<b>
<c>text</c>
<d>text</d>
</b>
</a>
So elements in level 1 can be in different order (b and e). Besides, elements in level 2 can also be in different order (g and f)
How can I do to have as a result similar and not identical ?
Thanks
Ahmed
The part of XMLUnit which decides which node to compare to which other node is controlled by the ElementQualifier. In your case it should work if you just used the ElementNameQualifier to make sure XMLUnit will compare the sub-trees with the same root names.