You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "Mannion, Enda" <en...@hp.com> on 2006/06/13 19:25:35 UTC

Copying nodes from different documents

Hi,

 

 

I have two xml documents and I want to copy a node from one document to
another.

 

This is the portion I want to copy.

 

-
<file:///C:\Program%20Files\Hewlett-Packard\RemoteSupport\data\1234045\m
etadata1234045.xml##> -
<file:///C:\Program%20Files\Hewlett-Packard\RemoteSupport\data\1234045\m
etadata1234045.xml##>  <annotations>

  <Annotation timestamp="15:47:24">add this on also</Annotation> 

  <Annotation timestamp="15:55:38">add this on also</Annotation> 

  <Annotation timestamp="16:07:12">add this on also</Annotation> 

  <Annotation timestamp="18:13:21">add this on also</Annotation> 

 </annotations>

    

 

  I find the node in one document and store the pointer in a DOMNode*
node.

 

   But when I do this I get an exception

   newNode->appendChild(node);

  

I get this exception: WRONG_DOCUMENT_ERR:

 

I know I am working off two different documents, so can someone suggest
how I go about doing this.

 

I even tried using the DOMNode* clone = node->cloneNode(true); function
and then appending te new cloned node. But got the same exception.

 

 

Enda 

 


Re: Copying nodes from different documents

Posted by Alberto Massari <am...@datadirect.com>.
At 18.25 13/06/2006 +0100, Mannion, Enda wrote:
>Hi,
>
>
>I have two xml documents and I want to copy a node from one document 
>to another.
>
>[...]
>   I find the node in one document and store the pointer in a DOMNode* node.
>
>    But when I do this I get an exception
>    newNode->appendChild(node);
>
>I get this exception: WRONG_DOCUMENT_ERR:
>
>I know I am working off two different documents, so can someone 
>suggest how I go about doing this.

newNode->appendChild(newNode->getOwnerDocument()->importNode(node));

Alberto 


---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org


Re: Copying nodes from different documents

Posted by Gareth Reakes <ga...@embracemobile.com>.
Hi,

	you need to import the node. Check out the methods on Document.

Gareth

Mannion, Enda wrote:
> Hi,
> 
>  
> 
>  
> 
> I have two xml documents and I want to copy a node from one document to 
> another.
> 
>  
> 
> This is the portion I want to copy.
> 
>  
> 
> *-* 
> <file:///C:\Program%20Files\Hewlett-Packard\RemoteSupport\data\1234045\metadata1234045.xml##>*-* 
> <file:///C:\Program%20Files\Hewlett-Packard\RemoteSupport\data\1234045\metadata1234045.xml##> 
> <annotations>
> 
> * * <Annotation timestamp="*15:47:24*">*add this on also*</Annotation>
> 
> * * <Annotation timestamp="*15:55:38*">*add this on also*</Annotation>
> 
> * * <Annotation timestamp="*16:07:12*">*add this on also*</Annotation>
> 
> * * <Annotation timestamp="*18:13:21*">*add this on also*</Annotation>
> 
> * *</annotations>
> 
>     
> 
>  
> 
>   I find the node in one document and store the pointer in a DOMNode* node.
> 
>  
> 
>    But when I do this I get an exception
> 
>    newNode->appendChild(node);
> 
>  
> 
> I get this exception: WRONG_DOCUMENT_ERR:
> 
>  
> 
> I know I am working off two different documents, so can someone suggest 
> how I go about doing this.
> 
>  
> 
> I even tried using the DOMNode* clone = node->cloneNode(true); function 
> and then appending te new cloned node. But got the same exception.
> 
>  
> 
>  
> 
> Enda
> 
>  
> 

-- 
Gareth Reakes, Managing Director           Embrace Mobile
+44-1865-811197              http://www.embracemobile.com

---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org