[Jsptest-svn-commits] SF.net SVN: jsptest: [233] trunk/jsptest-generic/jsptest-common/src/main/ ja
Status: Alpha
Brought to you by:
lkoskela
From: <lko...@us...> - 2008-06-27 11:32:50
|
Revision: 233 http://jsptest.svn.sourceforge.net/jsptest/?rev=233&view=rev Author: lkoskela Date: 2008-06-27 04:32:47 -0700 (Fri, 27 Jun 2008) Log Message: ----------- Now ignoring comments when collecting 'text content' Modified Paths: -------------- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java Modified: trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java =================================================================== --- trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java 2008-06-27 11:32:15 UTC (rev 232) +++ trunk/jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/XML.java 2008-06-27 11:32:47 UTC (rev 233) @@ -58,13 +58,16 @@ StringBuffer textContent = new StringBuffer(100); NodeList children = element.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - if (child.getNodeType() == Node.ELEMENT_NODE) { - textContent.append(textContentOf((Element) child)); - } else { - textContent.append(child.getNodeValue().trim()); - } + appendTextContentOf(children.item(i), textContent); } return textContent.toString(); } + + private static void appendTextContentOf(Node from, StringBuffer to) { + if (from.getNodeType() == Node.ELEMENT_NODE) { + to.append(textContentOf((Element) from)); + } else if (from.getNodeType() != Node.COMMENT_NODE) { + to.append(from.getNodeValue().trim()); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |