[jdom-interest] Setting / Adding Elements "in between"

Jason Hunter jhunter at servlets.com
Wed Aug 22 17:38:52 PDT 2001

ecky at free.fr wrote:
> Hi there,
> I wonder what is the destined way to insert / replace
> Child Elements of an element. I tried to get the list
> of elements (using getMixedContent) add/replace an
> element to/of it at the position I like, and try to
> use setMixedContent again for the changes to take
> effect - which throws an exception for the elements
> that were allready present. As I'm working on a lifelist
> I imagine the reason why. 

When you work with a live list, you don't need to call
setMixedContent().  The changes are immediate.  Calling
setMixedContent() causes errors because the elts you're adding are
already parented.

> Then I read in an old mail
> of Jason that I just should add the element to the
> life list and that's it (see full message at the end
> of this mail). 

I just said it again.  :-)

> This arises my question: Will this not
> lead to problems later on, as I don't see how the
> parent of the element inserted is being set?

The library takes care of it.

> Oh, BTW I'm using pre-beta0.7 loaded from CVS on 20.06.2001
> I'll try with the latest version as well

Yes, it's good to upgrade.


More information about the jdom-interest mailing list