code: public static String getElementContent(final Element el,
                                           final boolean trim) throws SAXException {
      StringBuilder sb = new StringBuilder();
  
      NodeList children = el.getChildNodes();
  
      for (int i = 0; i < children.getLength(); i++) {
        Node curnode = children.item(i);
  
        if (curnode.getNodeType() == Node.TEXT_NODE) {
          sb.append(curnode.getNodeValue());
        } else if (curnode.getNodeType() == Node.CDATA_SECTION_NODE) {
          sb.append(curnode.getNodeValue());
        } else if (curnode.getNodeType() == Node.COMMENT_NODE) {
          // Ignore
        } else {
          throw new SAXException("Unexpected child node " + curnode.getLocalName() +
                                 " for " + el.getLocalName());
        }
      }
  
      if (!trim) {
        return sb.toString();
      }
  
      return sb.toString().trim();
    }
docs: Return the content for the current element. All leading and trailing
  whitespace and embedded comments will be removed.
  
  <p>This is only intended for an element with no child elements.
  
  @param el
  @param trim true to trim surrounding white-space
  @return element content
  @throws SAXException