* It does need to have the other pieces.
*/
private static Element combineTextNodes(Element element) {
Element stub = new Element("a");
Comment stubc = new Comment("c");
StringBuffer sb = new StringBuffer();
int count = element.getChildCount();
for (int i = 0; i < count; i++) {
Node child = element.getChild(i);
if (child instanceof Text) {
sb.setLength(0);
do {
sb.append(child.getValue());
i++;
if (i == count) {
break;
}
child = element.getChild(i);
} while (child instanceof Text);
i--;
stub.appendChild(sb.toString());
}
else {
stub.appendChild(stubc.copy());
}
}
return stub;
}