<p>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.</p>

<p>At start:
XmlCursor poiting on
<code></p>

<p>&lt;a&gt;
  &lt;b&gt;
    some text
  &lt;/b&gt;
&lt;/a&gt;
</code></p>

<p>DOM Document:
<code></p>

<p>&lt;foo&gt;</p>

<p>&lt;/foo&gt;
</code></p>

<p>At the end I want to have original DOM document changed like this:
<code></p>

<p>&lt;foo&gt;</p>

<p>&nbsp;&nbsp;&lt;someOtherInsertedElement&gt;</p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&lt;a&gt;
  &lt;b&gt;
    some text
  &lt;/b&gt;
&lt;/a&gt;</p>

<p>&nbsp;&nbsp;&lt;/someOtherInsertedElement&gt;</p>

<p>&lt;/foo&gt;
</code></p>

<p>NOTE: <code>document.importNode(cursor.getDomNode())</code> doesn't work - Exception is thrown: <em>NOT_SUPPORTED_ERR: The implementation does not support the requested type of object or operation.</em></p>

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.