>how can I find out whether a node is a child of another node?
>"child.getParentNode() == parent" and 
>"child.getParentNode().equals(parent)" do not seem to work.

The latter shouldn't work; equals() is not defined for DOM nodes. (Do you 
mean "same node" or "equal content"?)

The former should work in Xerces... but is not portable; the DOM does not 
guarantee that object identity and node identity are the same thing.

The portable answer will be the DOM Level 3 isSameNode() method. 
Unfortunately, since Level 3 is not yet an official Recommendation, and 
since not all DOMs will implement Level 3, this is also not fully 
portable... but it's the best we're going to get.

Best recommendation I can offer you is to write a wrapper routine that 
checks which DOM implementation you're working with and uses isSameNode() 
if available and some fallback (probably ==) if not. Or accept that your 
code's going to be a bit nonportable, or is going to be locked into DOM3 
and later.


(As an alumnus of the DOM Working Group, I believe the official statement 
which covers this situation is "oops".)

______________________________________
Joe Kesselman  / IBM Research

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to