import org.xmlunit.builder.DiffBuilder; import org.xmlunit.builder.Input; import org.xmlunit.diff.Diff; public class XmlComparator { public static void main(String[] args) { String xml1 = "<root><name>John</name></root>"; String xml2 = "<root><name>Jane</name></root>"; Diff diff = DiffBuilder.compare(Input.fromString(xml1)) .withTest(Input.fromString(xml2)) .build(); if (diff.hasDifferences()) { System.out.println("XML documents are different"); } else { System.out.println("XML documents are identical"); } } }


上一篇:
下一篇:
切换中文