xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Linda Derezinski" <li...@interfacecontrol.com>
Subject RE: importNode() Problem
Date Fri, 05 May 2000 15:18:33 GMT
The node passed to importnode cannot have a parent.  In your example, node
is a member of document sXML1.
Just missing the call to cloneNode().


	Node newNode = node.cloneNode (true);
            doc2.importNode(newNode, true);

- Linda Derezinski
>  -----Original Message-----
> From: 	Tom Wnuk [mailto:twnuk@earthlink.net] 
> Sent:	Friday, May 05, 2000 11:00 AM
> To:	Apache XML General-Help
> Subject:	importNode() Problem
> 
> I'm trying to utilize importNode() as defined below.  I'm using xerces
> v1.0.3 and the it appears the importNode is not working.  
> 
> What am I doing wrong?
> 
> ==================
>         String sXML1 = "<?xml version=\"1.0\" ?>" +
>                         "<TEST><ResponseType>XML</ResponseType>" +
>                         "<StyleSheet>login.xsl</StyleSheet>" +
>                         "</TEST>";
>                         
>         try
>         {
>             Document doc1 = XMLHelper.getDocument(sXML1);
> 		    Element eRoot = doc1.getDocumentElement();        
>             NodeList nlTmp = eRoot.getElementsByTagName("ResponseType");
>             Node node = nlTmp.item(0);
>             
>             Document doc2 = XMLHelper.getDocument();
> 		    Element eNewRoot  = doc2.createElement("TEST");
> 		    doc2.appendChild(eNewRoot);		
>             
>             doc2.importNode(node, true);
>             
>             String sDoc2 = XMLHelper.makeStringFromDOM(doc2);
>             
>             System.out.println("sDoc=\n" + sDoc2);
>         }
> 
> ==================
> 
> Thanks 
> Tom
> 
> Tom Wnuk
> twnuk@earthlink.net
> twnuk@hotmail.com
>  << File: ATT00006.txt >> 

Mime
View raw message