[jdom-interest] why can't i do elementB.getContent().addAll(elementA.getContent())??

Phillip Rhodes spamsucks at rhoderunner.com
Thu Aug 22 20:18:09 PDT 2002


I want to move the content of Element A  to Element B

Example

Element elementA = getElementMethod();
Element elementB = new Element("newelement");
List listA = elementA.getContent();
elementB.getContent().addAll(listA);

The following will generate an error since the Elements, Text, CData 
objects have not been detached from the parent (elementA).  While I know I 
can loop through the list, and test for the type of object it is and call 
the detach method, I wonder if there is a easier way.  Don't you think 
there should be a convenience method somewhere to do this type of operation?
Thanks!









More information about the jdom-interest mailing list