[jdom-interest] Moving Subtrees using JDOM
Rocker Bill
r0cker at hotmail.com
Sat Feb 23 01:41:00 PST 2002
Thanks - works sweetly.
>From: Jason Hunter <jhunter at acm.org>
>To: Rocker Bill <r0cker at hotmail.com>
>CC: elharo at metalab.unc.edu, jdom-interest at jdom.org
>Subject: Re: [jdom-interest] Moving Subtrees using JDOM
>Date: Sat, 23 Feb 2002 00:53:16 -0800
>
>Rocker Bill wrote:
> >
> > Hi,
> >
> > Without getting myself too lost, I am trying to move a sequence of
>elements
> > with associated content from one top level parent to another, within the
> > same document... such as...
> >
> > <root>
> > <ele1>
> > <ele2>
> > <ele3/>
> > </ele2>
> > </ele1>
> > <ele4>
> > </ele4>
> > </root>
> >
> > In the above case, I want to move the subtree containing ele2 and ele3
>from
> > the parent, ele1, to beneath the new parent ele4 (ele2 and ele3 will
>also
> > have associated content).
>
>ele4.addContent(ele2.detach());
>
>That should be all you need. ele2 will take his children. We're
>talking about if you want to move ele1 and ele4 (siblings) to a
>different root that you have to do it iteratively.
>
>-jh-
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
More information about the jdom-interest
mailing list