Some API returns me XmlCursor pointing on root of XML Document. I need to insert all of this into another org.w3c.DOM represented document.
At start:
XmlCursor poiting on
<a>
<b>
some text
</b>
</a>
DOM Document:
<foo>
</foo>
At the end I want to have original DOM document changed like this:
<foo>
<someOtherInsertedElement>
<a>
<b>
some text
</b>
</a>
</someOtherInsertedElement>
</foo>
NOTE: document.importNode(cursor.getDomNode())
doesn't work – Exception is thrown: NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation.
Best Solution
Try something like this:
So in other words:
The reason to import is that a node always "belongs" to a given DOMDocument. Just adding the original node would cause exceptions.