>I have a Dom_Document and I have a node. I create a new document with
>the copy constructor.

>From a purist's point of view, you should instead be using the DOM's
cloneNode operation on the document, which will port more easily to other
DOM implementations.

>Is there any easy way to find the same node in the
>new document?

There's nothing built into the DOM for the purpose. Unless Xerces has a
custom feature which does this, your best bet is to essentially generate an
XPath to the old node, then execute that navigational sequence on the new
tree. Since you know the trees are identical (at least, until you mutate
one of them), it can be a relatively simple-minded implementation -- walk
up the parents, determining how many previous-siblings each parent has,
then use that information to walk down again from the root of the clone.

Possible pseudocode, untested:

     findCorrespondingNode(oldNode, newRootNode)
     {
          if(oldNode is the root node of its tree)
               return newRootNode;

          int n=(count oldNode's preceeding siblings);
          Node newParent=findCorrespondingNode(oldNode.getParent
(),newRootNode);
          return (newParent's nth child);
     }



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

Reply via email to