Java HTML Parse Jsoup isHTMLEmpty(String textToCheck)

Here you can find the source of isHTMLEmpty(String textToCheck)

Description

is HTML Empty

License

Open Source License

Declaration

public static boolean isHTMLEmpty(String textToCheck) 

Method Source Code

//package com.java2s;
/**/*www . j  ava  2s.c  om*/
* License: https://github.com/votingsystem/votingsystem/wiki/Licencia
*/

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class Main {
    public static boolean isHTMLEmpty(String textToCheck) {
        String emptyContent = "<p><br></p>";
        Document doc = Jsoup.parse(textToCheck);
        Elements elements = doc.select("body").first().children();
        if (elements.size() == 0)
            return true;
        for (Element el : elements) {
            if ("".equals(el.toString()) || emptyContent.equals(el.toString()))
                return true;
        }
        return false;
    }
}

Related

  1. getMetaValue(String html, String metaKey)
  2. getPlainText(String htmlText)
  3. getPlainTextFromHtml(String html)
  4. getTitle(String htmlContent)
  5. htmlArray2textArray(List htmlArray)
  6. parse(final String html)
  7. parse(InputStream input, String documentIRI, String encoding)
  8. parse(String html)
  9. parse(String html)