[jdom-interest] Placing Content in a Document

Jan Peter Hecking jan at netgaroo.com
Tue Feb 13 09:16:22 PST 2001


On Tue, 13 Feb 2001 14:01:48 -0200 Otavio Rezende da Silva wrote:
> I am trying to add child Elements into a Document using:
> document.getRootElement().addContent( element );
>  
> The element is always inserted as the last child of the RootElement. Is
> there any way of choosing the position of the new element inside its parent
> element when it is inserted?

Yes. Use the list returned by Element.getChildren(), e.g.
document.getRootElement().add( 0, element )
would add the element as the *first* child of the RootElement.

bye,
Jan

-- 
Jan Peter Hecking                  jhecking at netgaroo.com
University of Rostock     Department of Computer Science
Homepage: http://www.informatik.uni-rostock.de/~jhecking



More information about the jdom-interest mailing list