[jdom-interest] setText() to replace children?

Jon Baer jonbaer at digitalanywhere.com
Tue Jul 10 10:14:38 PDT 2001

Elliotte Rusty Harold wrote:

> Now that you mention it I don't like getText() either. It has the same problem setText() does: it really doesn't make sense when the element contains mixed content or even a child element. It violates the principal of least surprise. For example, consider this XHTML element:
> <p>
>   Do <strong>NOT</strong> eat the yellow snow!
> </p>
> Currently invoking getText() on the p element would produce the string "Do eat  the yellow snow!" This is very unexpected. Worse yet, it might 

There are some people who actually *NEED* that type of function and rely
on JDOM for it, technically NOT is not part of the "text" of <p> I
strongly beleive that if you need to recurse through it for text you
need another utility function like getPlainText(), etc.  

And I think if people lay down anything like
setText("<a>me<b>you</b></a>") that they are just being lazy.

- Jon

More information about the jdom-interest mailing list