java - Given a Node, how can I select the equivalent Node in a Document? -
    my caller handing me org.w3c.dom.node  , org.w3c.dom.document  serves owner document .  supplied node , in other words, guaranteed parented in supplied document , , represents node  in document  against work should performed.   i in position need clone document  (i need perform modifications, , cannot modify source.)   obviously, if that, node  still have in hand not owned new document  resulting clone.  have lost selection in cloned document .   however, know there node  in cloned document equal node  have in hand.  need find it.   what best way accomplish this, short of plowing through whole document  , calling isequalnode(node)  on each one?   i thought perhaps there way document.find(myunparentednode) , no such method exists.          you generate xpath describes position of node in old document , apply new document. see this question  approaches how that.   if it's possible modify node before cloning give unique attribute doesn't collide else (e.g. generated randomly) ...