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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top