How to compare two xmls who have same content, but different attribute orders?
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
精彩评论