Question: how can we convert html to well formed xhtml by using Http class api,if possible please give a
demonstration code....thanks

Answer: 
I just did it using Jsoup, if it works for you:

```
private String htmlToXhtml(final String html) {
    final Document document = Jsoup.parse(html);
    document.outputSettings().syntax(Document.OutputSettings.Syntax.xml);
    return document.html();
}

```

Some useful content where my solution came from:

* [Is it possible to convert HTML into XHTML with Jsoup 1.8.1?](https://stackoverflow.com/questions/29087077/is-it-possible-to-convert-html-into-xhtml-with-jsoup-1-8-1)
* <http://developers.itextpdf.com/question/how-do-html-xml-conversion-generate-closed-tags>
Have a look at J-Tidy: <http://jtidy.sourceforge.net/> It usually does a quite good job cleaning up messy html and converting it to xhtml.