PrathapR
5 years agoFrequent Contributor
How to print all differences when comparing two xml files using XMLUnit2
Hi All,
Using XMLUnit2 to compare two xml files using groovy in soapui, it's comparing two files successfully.Would like to print all differences what it finds, but it just printing only first difference. XMLUnit1 supposes to print all differences, but would like to use XMLUnit2.
If any one have any idea, how to print please help me, It would be appreciated.
Code Using:
diff = DiffBuilder.compare(resxml1)
.withTest( resxml2)
.withNodeFilter(nodeFilter)
.withAttributeFilter(attributeFilter)
.ignoreComments()
.ignoreWhitespace()
.ignoreElementContentWhitespace()
.checkForSimilar()
.withNodeMatcher(new DefaultNodeMatcher(new ByNameAndTextRecSelector(), ElementSelectors.byName))
.build();
print diff
.withTest( resxml2)
.withNodeFilter(nodeFilter)
.withAttributeFilter(attributeFilter)
.ignoreComments()
.ignoreWhitespace()
.ignoreElementContentWhitespace()
.checkForSimilar()
.withNodeMatcher(new DefaultNodeMatcher(new ByNameAndTextRecSelector(), ElementSelectors.byName))
.build();
print diff
- That is the default feature for XmlUnit.
Here you go to achieve what you are after
https://www.baeldung.com/xmlunit2