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
作为示例,xml1
和xml2
具有相同的内容,但属性具有不同的顺序,结果为false
。那么,如何比较这样的xmls?