Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Element.getValue()

xom-interest AT

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Dick H <dick AT>
  • To: xom-interest AT
  • Subject: [XOM-interest] Element.getValue()
  • Date: Thu, 22 May 2003 11:10:22 -0500

I am using 1.0d12, my first experience with XOM and am overjoyed.

Found one nuisance with Element.getValue() when applied to an Element that has both Text and Element children. I want just the concatonation of the Text nodes in the current Element. getValue() includes even the non-Text child nodes. Don't want that.

Either of these solutions would do:

1) Add a method Element.getText(), which is like getValue() but includes only the Text nodes of the current Element.

public final String /*getValue()*/ getText() {

StringBuffer result = new StringBuffer();
for (int i = 0; i < getChildCount(); i++) {
Node child = getChild(i);
if (child instanceof Text /*|| child instanceof Element */) {
return result.toString();


2) Change Element.getValue() to the above implementation

Archive powered by MHonArc 2.6.24.

Top of Page