code: public static String getText(final Node root) {
          if (root == null) {
              return "";
          } else {
              final StringBuilder result = new StringBuilder(1024);
              if (root.hasChildNodes()) {
                  final NodeList list = root.getChildNodes();
                  for (int i = 0; i < list.getLength(); i++) {
                      final Node childNode = list.item(i);
                      if (childNode.getNodeType() == Node.ELEMENT_NODE) {
                          final Element e = (Element) childNode;
                          final String value = e.getAttribute(ATTRIBUTE_NAME_CLASS);
                          if (!excludeList.contains(value)) {
                              final String s = getText(e);
                              result.append(s);
                          }
                      } else if (childNode.getNodeType() == Node.TEXT_NODE) {
                          result.append(childNode.getNodeValue());
                      }
                  }
              } else if (root.getNodeType() == Node.TEXT_NODE) {
                  result.append(root.getNodeValue());
              }
              return result.toString();
          }
      }
docs: Get text value of a node.
  
  @param root root node
  @return text value