[jdom-interest] elt.detach()

Jason Hunter jhunter at collab.net
Wed Dec 27 22:38:48 PST 2000


I believe it would be useful to have an element.detach() method that
removes an  element from its parent (if there is a parent), and returns
the detached element afterward.  This simplifies the act of moving an
element to a new location from this right now:

if (kid.getParent() != null) {
if (kid.getDocument() != null) {
  // see later discussion

to simply:


The only tricky thing is what to do if the Element being "detached" is a
root element, as shown above.  Technically just removing a root elt from
its document makes the document no longer well-formed.  So perhaps we
could do something like oldDoc.setRootElement(new



More information about the jdom-interest mailing list