Java Utililty Methods HTML Parse Jsoup

List of utility methods to do HTML Parse Jsoup

  1. HOME
  2. Java
  3. H
  4. HTML Parse Jsoup

Description

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

Method

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 cleanHtmlFromString(String stringToClean)
Utility to remove the HTML tags in the String
return Jsoup.clean(stringToClean, Whitelist.basic());
String cleanHTMLTags(String str)
Remove HTML tags.
if (str == null) {
 return null;
return Jsoup.parse(str).text();
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);
...


AltStyle によって変換されたページ (->オリジナル) /