[jdom-interest] Error handling

Scott Ellis scotey at pacbell.net
Mon Jan 3 10:17:18 PST 2005


I have an xml document that contains a root node and several children as


I parse this document, iterate the children, then attempt to apply ChildNode
to the database.  If there are any problems with the processing of ChildNode
to the database due to any SQL error, I create another document that has the
same structure, but contains only the ChildNode elements for which problems
occurred.  Then I write this new document to the file system in an error

This used to work, but it seems now that I changed something that is giving
me a problem.  The error reads something like  -- The Content already has an
existing parent "RootNode" --

I know the reason is that the ChildNode is already parsed and has an
existing parent from the parsed document, and that the new parent I am
creating has the same named parent, the question is how to get around it.

I create the document like this:

Element root = new Element( "RootNode" );
Document doc = new Document( root );
root.addContent( parsedElemFromOriginalDocument );



More information about the jdom-interest mailing list