code: public static String getElementNodeValue(Node node) {
          StringWriter sw = new StringWriter(2000);
          if (node.getNodeType() == Node.ELEMENT_NODE) {
              NodeList all = node.getChildNodes();
              for (int i = 0; i < all.getLength(); i++) {
                  if (all.item(i).getNodeType() == Node.TEXT_NODE ||
                      all.item(i).getNodeType() == Node.CDATA_SECTION_NODE) {
                      // TODO: Check if we exceed the limit for getNodeValue
                      sw.append(all.item(i).getNodeValue());
                  }
              }
          }
          return sw.toString();
      }
docs: Extracts all textual and CDATA content from the given node and its
  children.
  
  @param node the node to get the content from.
  @return the textual content of node.