import org.custommonkey.xmlunit.DetailedDiff;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
public class XmlComparisonExample {
public static void main(String[] args) {
String xml1 = "<root><name>John</name></root>";
String xml2 = "<root><name>Mike</name></root>";
XMLUnit.setIgnoreWhitespace(true);
Diff diff = new Diff(xml1, xml2);
if (diff.similar()) {
System.out.println("The XML documents are similar.");
} else {
DetailedDiff detailedDiff = new DetailedDiff(diff);
System.out.println("Differences found: " + detailedDiff.getAllDifferences());
}
}
}