How to avoid surrounding html head tags in Jsoup parse
final String html = "<p><b>This <i>is</i></b> <i>my sentence</i> of text.</p>"; Document docHtml = Jsoup.parse(html); Document docXml = Jsoup.parse(html, "", Parser.xmlParser()); System.out.println("******* HTML *******\n" + docHtml); System.out.println(); System.out.println("******* XML *******\n" + docXml);
final String html = "<p><b>This <i>is</i></b> <i>my sentence</i> of text.</p>"; Document doc = Jsoup.parseBodyFragment(html); doc.outputSettings().prettyPrint(false); System.out.println(doc.body().html());