java - Is it possible to convert HTML into XHTML with Jsoup 1.8.1? -
string body = "<br>"; document document = jsoup.parsebodyfragment(body); document.outputsettings().escapemode(escapemode.xhtml); string str = document.body().html(); system.out.println(str);
expect: <br />
result: <br>
can jsoup convert value html xhtml?
see document.outputsettings.syntax.xml
:
private string toxhtml( string html ) { final document document = jsoup.parse(html); document.outputsettings().syntax(document.outputsettings.syntax.xml); return document.html(); }
Comments
Post a Comment