import org.xmlunit.builder.DiffBuilder; import org.xmlunit.builder.Input; import org.xmlunit.diff.Diff; import org.xmlunit.diff.Difference; public class XmlComparator { public static void main(String[] args) { String originalXml = "<root><element1>value1</element1></root>"; String modifiedXml = "<root><element1>value2</element1></root>"; Diff xmlDiff = DiffBuilder.compare(Input.fromString(originalXml)) .withTest(Input.fromString(modifiedXml)) .build(); if (xmlDiff.hasDifferences()) { for (Difference difference : xmlDiff.getDifferences()) { System.out.println(difference); } } else { } } }


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