【发布时间】:2013-05-22 02:24:47
【问题描述】:
我正在使用 xmlunit 来比较两个文本文件。控件xml为:
<books>
<book>
<name>Angels & Demons</name>
<isbn>9971-5-0210-0</isbn>
<author>Dan Brown</author>
<category></category>
</book>
</books>
我将它与另一个交换了 and 元素的 xml 进行比较。
<books>
<book>
<isbn>9971-5-0210-0</isbn>
<name>Angels & Demons</name>
<author>Dan Brown</author>
<category></category>
</book>
</books>
Diff 对象报告以下差异:
Expected sequence of child nodes '1' but was '3' - comparing <name...> at /books[1]/book[1]/name[1] to <name...> at /books[1]/book[1]/name[1]
如果<name> 是子节点“1”,那么<isbn> 不是子节点“2”吗?
【问题讨论】:
-
似乎 XmlUnit 将 xml 中的回车计算为子节点。设置以下 XMLUnit.setIgnoreWhitespace(true); 给出了更直观的
Expected sequence of child nodes '0' but was '1' - comparing <int...> at /struct[1]/int[1] to <int...> at /struct[1]/int[1]结果