/** * Retrieves the string-value of an element node. This may be the empty string if the element is * empty, but must not be null. * * @param object the comment node. * @return Returns the string-value of the node. */ public String getElementStringValue(Object object) { if (isElement(object)) { return getStringValue((OMElement) object, new StringBuffer()) .toString(); } return null; }
private StringBuffer getStringValue(OMNode node, StringBuffer buffer) { if (isText(node)) { buffer.append(((OMText) node).getText()); } else if (node instanceof OMElement) { Iterator children = ((OMElement) node).getChildren(); while (children.hasNext()) { getStringValue((OMNode) children.next(), buffer); } } return buffer; }