Topic awaiting preservation: Comparing XML Elements |
|
---|---|
Author | Thread |
Maniac (V) Mad Scientist From: 100101010011 <-- right about here |
posted 05-28-2005 06:25
Hey I'm getting back to some JS roots and playing with some Ajax type stuff. |
Paranoid (IV) Inmate From: USA |
posted 05-28-2005 15:45
Well, the best way to compare two XML elements is recursively. The following algorithm isn't specific to XML nodes at all, just a general algorithm for testing two trees... code: function checkTree (node1, node2) { if(node1.value != node2.value) return false; else for(var i in node1.children) if(!checkTree(node1[i], node2[i])) return false; return true; }
|