<table><tr><!-- child 1 with one more child "td" as text (foo)--><td>foo</td></tr><tr><!-- child 2 with one more child "td" as text (bar)--><td>bar</td></tr></table>
bar
foo
To ignore the order of child1 and child2 while comparing using xmlunit we have RecursiveElementNameAndTextQualifier which can be overriden as following and works properly with no difference found.
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
Diff diff = new Diff(new FileReader("FILE1's Path"), new FileReader("File2's path"));
DetailedDiff myDiff = new DetailedDiff(diff);
myDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier ());
But in my case there are attributes instead text for example:
<table><tr><!-- child 1 with one more child "td" as attribute (foo)--><tdattr="foo"/></tr><tr><!-- child 2 with one more child "td" as attribute (bar)--><tdattr="bar"/></tr></table>
while comparing these two it gives the difference as:
"Expected attribute value 'bar' but was 'foo' - comparing at /table[1]/tr[1]/td[1]/@at to at /table[1]/tr[1]/td[1]/@at"
And I found that there no such Qualifier as RecursiveElementNameAndAttributeQualifier so that the difference can be ignored. I want to ignore the difference even when child is with attributes. Help me if any way you have.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To ignore the order of child1 and child2 while comparing using xmlunit we have RecursiveElementNameAndTextQualifier which can be overriden as following and works properly with no difference found.
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(true);
Diff diff = new Diff(new FileReader("FILE1's Path"), new FileReader("File2's path"));
DetailedDiff myDiff = new DetailedDiff(diff);
myDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier ());
But in my case there are attributes instead text for example:
while comparing these two it gives the difference as:
"Expected attribute value 'bar' but was 'foo' - comparing at /table[1]/tr[1]/td[1]/@at to at /table[1]/tr[1]/td[1]/@at"
And I found that there no such Qualifier as RecursiveElementNameAndAttributeQualifier so that the difference can be ignored. I want to ignore the difference even when child is with attributes. Help me if any way you have.