The reason is that the XMLUnit.compare(Element control, Element test) method uses Element.getText() that returns "" in the first example and "\n\r " in the second example for the <Dog> element.
I changed the code to ignore leading and trailing \n,\r,and \u0020. Are there better solutions?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have a problem comparing the following XML:
<Dog Name="Zombi"><Features Color="Black"/></Dog>
and
<Dog Name="Zombi">
<Features Color="Black"/>
</Dog>
The reason is that the XMLUnit.compare(Element control, Element test) method uses Element.getText() that returns "" in the first example and "\n\r " in the second example for the <Dog> element.
I changed the code to ignore leading and trailing \n,\r,and \u0020. Are there better solutions?
You should be able to call XMLUnit.setIgnoreWhitespace(true) which should make the two equivilent.
If it doesn't then this is a bug and I'll look into to it.
The source I downloaded does not have anything like setIgnoreWhitespace(). The timestamp of XMLUnit.java is 4/1/01 11:57, do you have newer source?
Sory, I see it is in the CVS. I'll try it.