xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
- From: Dick H <dick AT machj.com>
- To: xom-interest AT lists.ibiblio.org
- 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 */) {
result.append(child.getValue());
}
}
return result.toString();
}
2) Change Element.getValue() to the above implementation
-
[XOM-interest] Element.getValue(),
Dick H, 05/22/2003
- Re: [XOM-interest] Element.getValue(), Elliotte Rusty Harold, 05/22/2003
- <Possible follow-up(s)>
-
[XOM-interest] Element.getValue(),
Dick H, 05/22/2003
- Re: [XOM-interest] Element.getValue(), Nils_Kilden-Pedersen, 05/22/2003
Archive powered by MHonArc 2.6.24.