Java HTML Jsoup Document getAllText(Document document)

Here you can find the source of getAllText(Document document)

Description

get All Text

License

Open Source License

Declaration

public static String getAllText(Document document) 

Method Source Code


//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();
    }
}

Related

  1. applyCacheKeysToResourceUrls(Document document, long pluginModifiedTimestamp, Locale locale)
  2. convertLinksToAbsolute(String link, org.jsoup.nodes.Document doc)
  3. detectLanguage(Document doc)
  4. emptyDocument()
  5. formatDocument(Document doc)
  6. getCategoryIds(final Document html)
  7. getContainersForLink(Document document, String link)
  8. getDivForClass(Document document, String className)
  9. getDocument(CloseableHttpClient client, String url)