Here you can find the source of getAllText(Document document)
public static String getAllText(Document document)
//package com.java2s; //License from project: Open Source License import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.nodes.TextNode; public class Main { public static String getAllText(Document document) { StringBuilder text = new StringBuilder(); for (TextNode textNode : document.textNodes()) { text.append(textNode.getWholeText()); }/*from ww w . j a va 2s . c o m*/ return text.toString(); } public static String getAllText(Element element) { StringBuilder text = new StringBuilder(); for (Element child : element.getAllElements()) { text.append(child.text()); } return text.toString(); } }