You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Jason Rizer <ja...@yahoo.com> on 2001/03/29 04:28:39 UTC

New user having trouble moving a node

Hello.  I'm very new to XML in general and the Xerces
Java parser in particular.  I'm trying to copy an
Element from one document to another and I'm having
trouble.  I'm trying to do something like this:

Element tmpElement =  (Element) aNode.getFirstChild(
);

aNodeInADifferentDoc.appendChile(tmpElement);

This throws the exception DOM005 Wrong document.

Okay, so the node holds a reference to the document
which created it. How do I get around this?  I'm
almost at the point of creating a new node in the new
document and manually transferring all information
including subnodes, but there has to be an easier way!
 Anyone have any suggestions?  Thanks in advance.

-Jason



__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/?.refer=text

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: New user having trouble moving a node

Posted by Se...@cern.ch.
You have first to make your child adopted by the new document with
something like
  newDoc.adopt(child);
(I don't remember the syntax very precisely).
Then you can do an appendChild.

Sebastien

Jason Rizer wrote:

> Hello.  I'm very new to XML in general and the Xerces
> Java parser in particular.  I'm trying to copy an
> Element from one document to another and I'm having
> trouble.  I'm trying to do something like this:
>
> Element tmpElement =  (Element) aNode.getFirstChild(
> );
>
> aNodeInADifferentDoc.appendChile(tmpElement);
>
> This throws the exception DOM005 Wrong document.
>
> Okay, so the node holds a reference to the document
> which created it. How do I get around this?  I'm
> almost at the point of creating a new node in the new
> document and manually transferring all information
> including subnodes, but there has to be an easier way!
>  Anyone have any suggestions?  Thanks in advance.
>
> -Jason
>
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/?.refer=text
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org