[jdom-interest] Merging a root element into another document
Tim Sutton
tim at linfiniti.com
Sun Aug 24 17:05:00 PDT 2003
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi
I am trying to merge several jdom documents together:
org.jdom.Element myRootElement = new org.jdom.Element("MasterDocument");
//toplevel xml element
org.jdom.Document myDocument = new org.jdom.Document(myRootElement);
//get the document to be merged in
Document myDocument = childDocument.toDom();
//add child document record element to document root
myRootElement.addContent(myDocument.getRootElement());
When run this gives the following error:
Exception in thread "main" org.jdom.IllegalAddException: The element
"ChildDocument" could not be added as a child of "MasterDocument":
The element already has an existing parent (the document root)
at org.jdom.Element.addContent(Element.java:1172)
How do I incorporate the root element (and its children) from one document as
the child element of another document?
Thanks in advance.
Tim Sutton
- --
Get my public keys from:
http://tim.suttonfamily.co.uk/modules.php?name=Content&pa=showpage&pid=2
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
iD8DBQE/SVKtWvXTJUo0BDoRAuCnAJ4z2MH2WbEyY0DbbzzRsV/Z6wnDsQCfWIbZ
r6B1E+Hmfwe2/x4Wcm/8wiQ=
=vN9E
-----END PGP SIGNATURE-----
More information about the jdom-interest
mailing list