> Is there a way to make Element.addContent add the content at a
> specific location?
[quoted text clipped - 5 lines]
>
> Is there a way to add an element at a specific location?
I use Element.insertBefore( Node newChild, Node refChild );
chiry@csua.berkeley.edu writes in article <bjtl91$1rtr$1@agate.berkeley.edu> dated Fri, 12 Sep 2003 23:36:01 +0000 (UTC):
>Is there a way to make Element.addContent add the content at a
>specific location?
No, not AFAIK.
>I need to update an existing jdom object in memory, by adding/removing
>some elements. problem is, addContent() always add at the end, and as
>a result the resulting XML object doesn't validate against the XSD
>file.
>
>Is there a way to add an element at a specific location?
Yes. You can use Element.getContent() to get the content as a List, then use
List.add(int, Object) to insert the new content wherever you see fit.
Caution -- You can add any object to the content this way, only some of
which are valid in JDOM.
--Keith Lewis klewis$mitre.org
The above may not (yet) represent the opinions of my employer.