[jdom-interest] Moving elements closer to the root

Amy Lewis amyzing at talsever.com
Mon May 7 20:16:32 PDT 2001


On Tue, May 08, 2001 at 01:37:30AM +0100, Thomas Nichols wrote:
>Good Day,
>Previous discussions on detach() et al haven't yet guided me to a solution 
>to this one - all help welcome.
>I want to convert
><a>
>   <b>
>     <c>
>     Some mixed content.
>     </c>
>   </b>
></a>
>
>to
><a>
>   <c>
>   Some mixed content.
>   </c>
></a>
>
>i.e. I want to make the _child_ part of the content of the _grandparent_, 
>making the parent redundant.
>
>If Element grandParent is <a>, parent is <b> and child is <c>, I'm trying 
>the following:
>
>grandParent.removeContent (parent);
>grandParent.addContent (child);

Between those two statements, add:
parent.removeContent(child);

Although you've removed parent from grandparent, since child still has
a parent (parent), it can't have another one (JDOM is into single
motherhood).  You have to orphan it, first.

Amy!
-- 
Amelia A. Lewis          alicorn at mindspring.com          amyzing at talsever.com
So what is love then?  Is it dictated or chosen?  Does it sing like the 
hymns of a thousand years or is it just pop emotion?  And if it ever was 
here and it left does it mean it was never true?
                                                -- Emily Saliers



More information about the jdom-interest mailing list