<a>12</a> represents an element with a single child element node with a value of "12", while <a>{1}2</a> represents an element with two child nodes with a value of "1" and "2" respectively.
They are logically distinguishable in Scala: x.child is ArrayBuffer(12) , while y.child is ArrayBuffer(1, 2) , and therefore they are unequal.
What about the XML specification? According to my data, these two XML objects are not equal. According to the XML specification , the content of an element consists of a sequence of one or more things (which the DOM calls "nodes"), and these things can be CharData . Therefore, it is logical that an element has two adjacent CharData children, and this is considered to be logically different from one concatenated CharData child.
If you really want to consider them equal, you should write a normalization pass that takes an XML object and concatenates any adjacent text nodes, and then performs an equality test.
mgiuca
source share