Java HTML Parse Jsoup tidyHtml(String html)

Here you can find the source of tidyHtml(String html)

Description

tidy Html

License

Apache License

Declaration

public static String tidyHtml(String html) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Entities;

public class Main {

    public static String tidyHtml(String html) {
        Document doc = Jsoup.parse(html);
        // Clean the document.
        //doc = new Cleaner(Whitelist.basicWithImages()).clean(doc);
        doc.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
        doc.outputSettings().prettyPrint(true);

        doc.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
        // Get back the string of the body.
        return doc.html();
    }/*  ww  w .  j ava  2s  .  c o m*/
}

Related

  1. removeHTMLTags(final String text)
  2. removeTag(String html)
  3. sanitizeHTML(String html)
  4. stripHTML(final String value)
  5. stripHtml(String html)
  6. truncateHTML(String content, int len)
  7. unescapeHtml(String str)