Java HTML Jsoup Document keepLineBreak(Document docRes)

Here you can find the source of keepLineBreak(Document docRes)

Description

keep Line Break

License

Open Source License

Declaration

public static String keepLineBreak(Document docRes) 

Method Source Code

//package com.java2s;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.safety.Whitelist;

public class Main {

    public static String keepLineBreak(Document docRes) {
        docRes.outputSettings(new Document.OutputSettings().prettyPrint(false));// makes html() preserve linebreaks and spacing
        docRes.select("br").append("\\n");
        docRes.select("p").prepend("\\n\\n");
        String result = docRes.html().replaceAll("\\\\n", "\n");
        result = Jsoup.clean(result, "", Whitelist.none(), new Document.OutputSettings().prettyPrint(false));
        return result;
    }/*from  ww  w. j  a  v  a 2s.  c o  m*/
}

Related

  1. getJSoupHtmlDocument(final String url)
  2. getJSoupXmlDocument(final String url)
  3. getLoginFields(Document doc)
  4. getTextFromAvailableDivID(Document doc, String divID)
  5. getTitleFromDocument(Document doc)
  6. makeAbsolute(Document doc)
  7. normalizeWhitespaces(Document doc)
  8. postDocument(String url, Collection data)
  9. removeTag(Document doc, String selector)