Let's say we have an org.w3c.dom.Document representing the following XML:
<Fruits>
<Apples>
<Red/>
<Green/>
</Apples>
</Fruits>
If we know that the document always will contain a <Fruits>
root with only one child (in this case <Apples>
, but the name of the child is generally unknown), how can we make that child the root of a new org.w3c.dom.Document? In other words, this new document should represent the following XML:
<Apples>
<Red/>
<Green/>
</Apples>
My problem is that when I try to extract the child, I can't make it forget its parent (it still remembers its position in the original document).