Try something like this:
Node originalNode = cursor.getDomNode();
Node importNode = document.importNode(originalNode.getFirstChild());
Node otherNode = document.createElement("someOtherInsertedElement");
otherNode.appendChild(importNode);
document.appendChild(otherNode);
So in other words:
- Get the DOM Node from the cursor. In this case, it's a DOMDocument, so do getFirstChild() to get the root node.
- Import it into the DOMDocument.
- Do other stuff with the DOMDocument.
- Append the imported node to the right Node.
The reason to import is that a node always "belongs" to a given DOMDocument. Just adding the original node would cause exceptions.
Sietse
2008-09-17 13:34:37