[jdom-interest] Moving elements closer to the root [RESOLVED]

Thomas Nichols thomas.nichols at iname.com
Tue May 8 02:50:04 PDT 2001


At 23:16 07/05/2001 -0400, Amy Lewis wrote:
>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!

Thanks Amy - that was indeed the problem, now works as intended.

Best Regards,
Thomas.






More information about the jdom-interest mailing list