You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ma...@apache.org on 2004/07/17 00:46:46 UTC
cvs commit: jakarta-slide/src/util/org/apache/util DOMUtils.java
masonjm 2004/07/16 15:46:46
Modified: src/util/org/apache/util DOMUtils.java
Log:
DOMUtils.getTextValue() now gets text recursively, not just from immediate children.
Revision Changes Path
1.8 +10 -11 jakarta-slide/src/util/org/apache/util/DOMUtils.java
Index: DOMUtils.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/util/org/apache/util/DOMUtils.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DOMUtils.java 11 Feb 2004 11:30:23 -0000 1.7
+++ DOMUtils.java 16 Jul 2004 22:46:46 -0000 1.8
@@ -134,8 +134,7 @@
/**
- * Scan all immediate children of a node, and append all
- * text nodes into a string. Consider the following example
+ * Recursively scans all child elements, appending any text nodes.
*
* <PRE>
* <customer>Joe Schmoe</customer>
@@ -151,11 +150,11 @@
String text = "";
NodeList textList = node.getChildNodes();
for (int i = 0; i < textList.getLength(); i++) {
- try {
- text += ((Text) textList.item(i)).getData();
- } catch (ClassCastException e) {
- // we don't care about non-Text nodes
- }
+ if (textList.item(i).getNodeType() == Node.TEXT_NODE) {
+ text += ((Text) textList.item(i)).getData();
+ } else {
+ text += getTextValue(textList.item(i));
+ }
}
return text;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org