开发者

How to compare two xmls who have same content, but different attribute orders?

开发者 https://www.devze.com 2023-02-22 04:12 出处:网络
scala> val xml1 = 开发者_运维百科<a method=\"1\" href=\"2\" ref=\"3\" onclick=\"4\">Hello</a>
scala> val xml1 = 开发者_运维百科<a method="1" href="2" ref="3" onclick="4">Hello</a>
xml1: scala.xml.Elem = <a ref="3" href="2" onclick="4" method="1">Hello</a>

scala> val xml2 = <a ref="3" href="2" onclick="4" method="1">Hello</a>
xml2: scala.xml.Elem = <a href="2" ref="3" onclick="4" method="1">Hello</a>

scala> xml1 == xml2
res8: Boolean = false

As the sample, xml1 and xml2 have same content, but the attributes have different orders, and the result is false. So, how to compare such xmls?


This looks like the tool for you:

xml-test: A diff-like tool for XML

0

精彩评论

暂无评论...
验证码 换一张
取 消