How to avoid surrounding html head tags in Jsoup parse

后端 未结 4 1204
别跟我提以往
别跟我提以往 2020-12-06 16:26

Using Jsoup i try to parse the given html content. After Jsoup.parse() the html output append html, head and body tag to the input. I just want to ignore these.

4条回答
  •  伪装坚强ぢ
    2020-12-06 17:03

    To get the expected output it would actually be:

    final String html = "

    This is my sentence of text.

    "; Document doc = Jsoup.parseBodyFragment(html); doc.outputSettings().prettyPrint(false); System.out.println(doc.body().html());

提交回复
热议问题