[jdom-interest] setText() to replace children?
bob at werken.com
Wed Jul 11 05:53:46 PDT 2001
On Wed, 11 Jul 2001, Bart Read wrote:
> I have to broadly agree with Alex Rosen on this one. getText() should just
> get the text, possibly throwing a RuntimeException if there is mixed
> content. If you want all of the content you should use getContent(). I
> think the function that setText() should perform is more open to debate.
Figured I'd finally chime in...
Everything, from Elements which have only text, to Elements which have
mixed content, has a textual representation, which is use heartily in
I like <b>cheese</b>
The text, in xpath realms of thinking, is "\nI like cheese\n"
It's a recursive evaluation of the text of all descendants.
I certainly don't think that setText(...) should be recursive,
so for symmetry, getText() should not be either.
But, there is obviously a call from some folks to have a recursive-esque
So, maybe a getXPathText(), or a getText(boolean recurse).
String getText(boolean recurse)
if ( ! recurse )
... return complex recursive assembly of text ...
More information about the jdom-interest