P
psaffrey
I'd like a test for node equivalence, rather than node equality.
Basically, I'd like the following two files to be considered
"equivalent":
<base id="base">
<element1 attr="value1" id="value1" name="mainelem">
<subelement id="sub1" name="s">Something</subelement>
<subelement id="sub3" name="as">Another something</subelement>
</element1>
</base>
and
<base id="base">
<element1 attr="value1" id="value1" name="mainelem">
<subelement id="sub3" name="as">Another something</subelement>
<subelement id="sub1" name="s">Something</subelement>
</element1>
</base>
I tried using isEqualNode, but this is sensitive to childNode
ordering. I also considered trying to normalize both files by sorting
the childNodes of each element, but nodeList objects don't seem to
support sorting (at least in my DOM implementation). The DOM normalize
function is designed more for combining the contents of text elements
than this kind of operation.
Any ideas?
Peter
Basically, I'd like the following two files to be considered
"equivalent":
<base id="base">
<element1 attr="value1" id="value1" name="mainelem">
<subelement id="sub1" name="s">Something</subelement>
<subelement id="sub3" name="as">Another something</subelement>
</element1>
</base>
and
<base id="base">
<element1 attr="value1" id="value1" name="mainelem">
<subelement id="sub3" name="as">Another something</subelement>
<subelement id="sub1" name="s">Something</subelement>
</element1>
</base>
I tried using isEqualNode, but this is sensitive to childNode
ordering. I also considered trying to normalize both files by sorting
the childNodes of each element, but nodeList objects don't seem to
support sorting (at least in my DOM implementation). The DOM normalize
function is designed more for combining the contents of text elements
than this kind of operation.
Any ideas?
Peter