The list of methods to do HTML Parse Jsoup are organized into topic(s).
String
br2nl(String html) brnl
if (html == null)
return html;
return Jsoup.parse(html).text().replaceAll("\\<.*?>", "");
String
clean(String html) clean
if (html == null || html.trim().length() < 1) {
return "";
return Jsoup.clean(html, getWhitelist());
String
clean(String html, Whitelist whitelist) Cleans the specified HTML with the specified white list.
Document doc = parse(mask(html));
Cleaner cleaner = new Cleaner(whitelist);
Document clean = cleaner.clean(doc);
clean.outputSettings().prettyPrint(false);
return unmask(normalizeWhitespaces(clean).body().html());
String
cleanHTML(final String html) Remove most unsafe tags and attributes, leaving mostly format tags and links.
return html != null ? Jsoup.clean(html, Whitelist.basic()) : null;
String
cleanHtmlCode(String html) clean Html Code
String s = html;
s = s.replaceAll("(</?(p|div)|<br( ?/)?>)", "#####1ドル");
s = Jsoup.parse(s).text();
s = s.replaceAll("#####", "\n");
StringBuilder sb = new StringBuilder();
for (String line : s.split("\n")) {
String trimmed = line.trim();
if (!trimmed.isEmpty()) {
...
String
cleanupHtmlDoc(String s) cleanup Html Doc
if (s != null) {
Document doc = Jsoup.parse(s);
doc.outputSettings().prettyPrint(true);
s = doc.toString();
return s;
String
clearBody(String html) clear Body
Document document = Jsoup.parse(html);
document.outputSettings(new Document.OutputSettings().prettyPrint(false));
document.select("br").append("\n");
document.select("p").prepend("\n");
String result = Jsoup.clean(document.html(), "", Whitelist.none(),
new Document.OutputSettings().prettyPrint(false));
result = result.replace("\r", "\n");
result = result.replace("\n ", "\n");
...
Element
coverTag(String html, String... tagNames) cover html by tagNames by first element of tagName will be outermost.
List<String> tags = Arrays.asList(tagNames);
Collections.reverse(tags);
Element e = null;
for (String s : tags) {
if (e == null)
e = addTag(html, s);
else
e = addTag(e, s);
...