views:

3460

answers:

4

Hi

I am trying to parse HTML in android from a webpage, and since the webpage it not well formed, I get SAXException.

Is there a way to parse HTML in android?

(my guess is not, so the follow up question is: what is the best way to do this? )

Thanks

+4  A: 

There are many Java HTML parsers. Whether any work on Android, I can't say. I've seen people experiment with TagSoup, based on other posts here in SO.

CommonsWare
+4  A: 

Have you tried using Html.fromHtml(source)?

I think that class is pretty liberal with respect to source quality (it uses TagSoup internally, which was designed with real-life, bad HTML in mind). It doesn't support all HTML tags though, but it does come with a handler you can implement to react on tags it doesn't understand.

Matthias
A: 

Html.fromHtml() supports only few tags.How to use the Handler according to you.Can u please explain with a sample code.

Regards,

vani

vani
You should post follow-up questions as a separate thread, notas an answer. After all, it doesn't really answer *this*question. Also more people would see it and try to answer if you post it asyour own question.You can of course always link back to this question for reference.
sth
A: 

Maybe you can use WebView, but as you can see in the doc WebView doesn't support javascript and other stuff like widgets by default.

http://developer.android.com/reference/android/webkit/WebView.html

I think that you can enable javascript if you need it.

oropher