Forum Discussion
- PrathapR5 years agoFrequent Contributor
Thank you for your response nmrao ,
Used below code
resXML1 = xmlParser.parse("C:\\TestCase_TC1_JS.xml")
resXML2 = xmlParser.parse("C:\\TestCase_TC2_KS.xml")
resXML11 = XmlUtil.serialize(resXML1)
resXML22 = XmlUtil.serialize(resXML2)//Compare two Responses
//assert(resXML22 == resXML11) : "Res1 Doesn't Match with Res2"
diff = new Diff(resXML22, resXML11)XMLUnit.setIgnoreComments(Boolean.TRUE);
XMLUnit.setNormalizeWhitespace(Boolean.TRUE); //Ignore WhiteSpace
XMLUnit.setIgnoreDiffBetweenTextAndCDATA(Boolean.TRUE); //Ignore Text and CDATA
XMLUnit.setIgnoreAttributeOrder(Boolean.TRUE); //Ignore Attribute Order
try {
log.info (diff.similar());
log.info(diff.identical());
DetailedDiff detDiff = new DetailedDiff(diff);
detDiff.overrideElementQualifier(new ElementNameAndAttributeQualifier());
detDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
List differences = detDiff.getAllDifferences();
for (Object object : differences) {
Difference difference = (Difference)object;
log.info("***********************");
log.error(difference);
log.info("***********************");
}
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}Also used/tried from your git code
https://github.com/nmrao/groovyScripts/blob/master/compare/CompareWithIgnoreElements.groovy
but in this I can able to ignore nodes and attributes. not bale to do the above mentioned lines.
Related Content
- 2 years ago
- 2 years ago
- 7 years ago