在考虑以下约束的情况下比较两个XML对象: 1)忽略白色空间 2)忽略数组顺序 3)忽略包含日期的一些元素 请帮我考虑第3个约束 以下是我尝试过的代码:
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreAttributeOrder(true);
DetailedDiff diff = new DetailedDiff(XMLUnit.compareXML(expectedXML, actualXML));
List<?> allDifferences = diff.getAllDifferences();
if(allDifferences.size() == 0)
System.out.println("Test Passed");
else
System.out.println("Test failed due to following differences: ");
for(int differences = 0; differences < allDifferences.size(); differences++) {
System.out.println(allDifferences.get(differences));