问题
Title says it all. How to do that with Jsoup? I don't need a file. Just XHTML to use. I've only found some examples with bytearrays and fileoutputs. I only need a valid XHTML to use with itext PdfWriter and XMLWorker later on.
回答1:
I believe something like this would do the trick
Document doc = Jsoup.parse(html);
doc.outputSettings().escapeMode(Entities.EscapeMode.xhtml); //This will ensure the validity
doc.outputSettings().charset("UTF-8");
System.out.println(doc);
来源:https://stackoverflow.com/questions/28876603/jsoup-how-to-convert-a-string-containing-html-to-a-xhtml-document