Y
yio
Hi,
I'm posting an answer for people looking about the same thing.
private Document createNewDOM(Document srcDocument) {
try {
//Create the resulting DOM
Document resultDocument =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
//import an element (here, it is the root element) from first DOM
DocumentFragment df = srcDocument.createDocumentFragment();
documentFragment.appendChild(srcDocument.getDocumentElement());
//Create the Node to append to the new DOM
Node importNode = resultDocument.importNode(documentFragment,
true);
resultDocument.appendChild(importNode);
}
catch (Exception e) {
e.printlnStackTrace();
}
finally {
return resultDocument;
}
hope that help!!
Bye
Lionel
I'm posting an answer for people looking about the same thing.
private Document createNewDOM(Document srcDocument) {
try {
//Create the resulting DOM
Document resultDocument =
DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
//import an element (here, it is the root element) from first DOM
DocumentFragment df = srcDocument.createDocumentFragment();
documentFragment.appendChild(srcDocument.getDocumentElement());
//Create the Node to append to the new DOM
Node importNode = resultDocument.importNode(documentFragment,
true);
resultDocument.appendChild(importNode);
}
catch (Exception e) {
e.printlnStackTrace();
}
finally {
return resultDocument;
}
hope that help!!
Bye
Lionel