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 into XHTML?
You should tell that syntax you want to leave the string in HTML or XML.
You can use JTidy API to do this. Use jtidy-r938.jar
You can use the following method to get xhtml from html
See
Document.OutputSettings.Syntax.xml
: