Sunday, October 11, 2009

The Content already has an existing parent

If you want to make a new XML Document using JDom from a node in another XML document, you first need to remove that node from the parent XML document using detach() method.

If you try to create a new XML Document using the node before detaching it you get this error message:

The Content already has an existing parent [some parent node name].

I'm sure there is a reason why this is the error message but when you're using a node to create a new XML document the error message makes little sense to me in this particular context.