Here you can find the source of stripEmptyDivs(Element body)
private static void stripEmptyDivs(Element body)
//package com.java2s; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; public class Main { private static void stripEmptyDivs(Element body) { stripEmptyTag(body, "div"); }/*w w w. j a v a 2s . c om*/ private static void stripEmptyTag(Element body, String tag) { Elements elements = body.select(tag); for (Element e : elements) { if ((e.html() == null || e.html().trim().length() == 0) && (e.text() == null || e.text().trim().length() == 0)) { e.remove(); } } } }