[jdom-interest] Element.setContent

Alex Chaffee guru at edamame.stinky.com
Wed Oct 4 12:28:26 PDT 2000

> Element.setContent(String) clears the linked list.  Is that the
> desired result?  All the children of that element are gone when I
> change the content.  If it should clear the list then shouldn't
> there be a Element.getContent() that returns a List instead of a
> string.  And a Element.setContent(List)?

Look at Element.getMixedContent()

public java.util.List getMixedContent()

	This returns the full content of the element as a List which may
	contain objects of type String, Element, Comment,
	ProcessingInstruction, and Entity. When there is technically no mixed
	content and all contents are of the same type, then all objects
	returned in the List will be of the same type. The List returned is
	"live" and modifications to it affect the element's actual
	contents. Whitespace content is returned in its entirety.

(Yes, if it had been called getContentMixed or getContentFull, it
would show up in the alphabetical Javadoc next to getContent(), but
that's no excuse for not reading the whole API, Jim :-))

 - A

Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/

More information about the jdom-interest mailing list