> DocumentImpl newdoc = new DocumentImpl();
> 
> //get xmldoc of an xml file
> Document xmldoc = file2Document("note.xml");
> 
> 
> if(xmldoc != null)
> {
>   // get root node of the read xml file
> 
> Element notifyNode =
> (Element)xmldoc.getDocumentElement();
> 
>   Element root = newdoc.createElement("new");
> 
>   root.appendChild(notifyNode);
                        ^^^^^
        
As  'notifyNode' node is from different 'document', u have to import this 'node'
first into ur 'document' like

Node node = newdoc.importNode(notifyNode,true);

and then use this 'node' to append to the 'node'(root) of current document like

root.appendChild(node);

so,

-  root.appendChild(notifyNode);

+ Node node = newdoc.importNode(notifyNode,true);
+ root.appendChild(node);


However, be careful  of the usage of this method, besides taking 'node' as input
parameter, it takes another parameter of type 'boolean'. If 'true' this method
recursively import the subtree under the specified node; if false, imports only 
the node itself.

For more information refer to, 

http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010913/core.html#i-Document



--
Neeraj Bajaj
Sun Microsystems, inc.

Phone: 080-2298989 x87425.




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

Reply via email to