Java Utililty Methods HTML Parse Jsoup

List of utility methods to do HTML Parse Jsoup

Description

The list of methods to do HTML Parse Jsoup are organized into topic(s).

Method

StringstripHtml(String html)
strip Html
return Jsoup.parse(html).text().replace("\u00a0", "");
StringtidyHtml(String html)
tidy Html
Document doc = Jsoup.parse(html);
doc.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
doc.outputSettings().prettyPrint(true);
doc.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
return doc.html();
StringtruncateHTML(String content, int len)
truncate HTML
Document dirtyDocument = Jsoup.parse(content);
Element source = dirtyDocument.body();
Document clean = Document.createShell(dirtyDocument.baseUri());
Element dest = clean.body();
truncateHTML(source, dest, len);
return dest.outerHtml().replace("<body>", "").replace("</body>", "");
StringunescapeHtml(String str)
unescape Html
return Parser.unescapeEntities(str, false);