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 ; }
To get all the textual content in the dom