lb said:
Anyone know if there's a fast way to copy childNodes from one XML document
to another using Oracle XML?
What about Apache XML?
If you use the W3C DOM Document object then you can use the method
importNode to import nodes from another document and you can then append
them to your document:
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class Test20040427 {
public static void main (String[] args) {
try {
DocumentBuilderFactory documentBuilderFactory =
DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder =
documentBuilderFactory.newDocumentBuilder();
Document xmlDocument1 = documentBuilder.parse("test20040427.xml");
Document xmlDocument2 = documentBuilder.newDocument();
xmlDocument2.appendChild(xmlDocument2.importNode(xmlDocument1.getDocumentElement(),
true));
System.out.println("xmlDocument2.getDocumentElement().getNodeName(): " +
xmlDocument2.getDocumentElement().getNodeName());
}
catch (Exception e) {
System.out.println("Error: " + e);
}
}
}
Both Apache and Oracle parsers should support JAXP
DocumentBuilderFactory/DocumentBuilder and the W3C Document interface
but you can simply work with the Sun JDK 1.4 as it has all that is needed