code: public static String getTextContent(Document document, boolean individualTokens) {
          String textContent = null;
          if (individualTokens) {
              List<String> tokens = getTextTokens(document);
              textContent = StringUtils.join(tokens, ",");
          } else {
              textContent =
                      document.getDocumentElement().getTextContent().trim().replaceAll("\\s+", ",");
          }
          return textContent;
      }
docs: To get all the textual content in the dom
  
  @param document
  @param individualTokens : default True : when set to true, each text node from dom is used to build the
  text content : when set to false, the text content of whole is obtained at once.
  @return