[jdom-interest] Moving Children
Jason Hunter
jhunter at acm.org
Thu Jun 7 16:32:43 PDT 2001
Kevin Baynes wrote:
>
> I have two nodes that have children. I would like to take all the children
> from one node and move them to the other. Is there a way to do this
> *without* looping through each of the children to move and calling
> Element.detach() ?
Get the first list, clone it (a shallow clone), call clear() on the
list, then call addAll() passing the cloned list. Behind the scenes
detach() will be called but you don't have to do it.
Note this may not work perfectly with the internal PartialList impl,
which is why we're changing to FilterList.
> Question: The above code will generate an error because all of the children
> of groupTwo already have a parent, correct?
Yep.
-jh-
More information about the jdom-interest
mailing list