Node equivalence

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
 
J

Joseph Kesselman

I'd like a test for node equivalence, rather than node equality.
Basically, I'd like the following two files to be considered
"equivalent":

I think this is a "write it yourself" problem, since only you know what
your application considers equivalent or not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,058
Latest member
QQXCharlot

Latest Threads

Top