2

我想知道是否有人知道用于衡量 HTML 等效性的 Java 库?

例如<td class="one two three" name="goat">将等价于<td name="goat" class="three two one">. 我想使用 Java 以这种方式比较整个多行 html 字符串。

有什么建议么?

更新:

所以我尝试使用 XmlUnit 的 Diff.similar() 并发现我得到这两个是相似的:

<html three="3" two="2" one="1"></html><html one="one" two="two"></html>

这是不受欢迎的行为......还有其他选择吗?

4

1 回答 1

2

您可以使用像NekoHTMLJTidy这样的 html 解析器,然后使用XMLUnit的Diff类来比较两个 XML 文档。

于 2010-01-27T17:58:41.743 回答