我正在尝试查看是否可以使用 XMLUnit 来比较以下两个不同的 XML。我使用 Diff 类来比较以下两个 XML 并检查相似的返回 false。
XML One
<Required>
<Question desc="Are you single?">
<Answers>
<Answer value="Yes"/>
<Answer value="No"/>
</Answers>
</Question>
</Required>
XML Two
<Required>
<Question desc="Are you single?">
<Answers>
<Answer value="No"/> ''Order is reversed in XML two
<Answer value="Yes"/>
</Answers>
</Question>
</Required>
这是我的 JAVA 代码:
Diff xmlDiff;
try {
xmlDiff = new Diff(xmlOne, xmlTwo);
xmlDiff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
} catch (Exception e) { }
boolean isEqual = xmlDiff.similar()