[jdom-interest] Problem: element already has an existing parent

Kuehnberger Kuehnberger at web.de
Mon Oct 22 00:39:37 PDT 2001

Hi I try to get an xml document like


where page must be dynamically set, when a condition applies.
For that I tried something like

Document doc = null;
Element root = new Element("root");
Element page = new Element("page");
Element a = new Element("a");
while (b) {
    Element b = new Element("b");
    if (condition applies) {
       a = new Element("a");
       page = new Element("page");

if try that, I get :
The element "page" could not be added as a child of "root": The element
already has an existing parent "root".

How can achieve something like that?


More information about the jdom-interest mailing list