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?
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?
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.
I just encountered this problem. I tried a few things, but settled on using JSoup. The jar is about 132k, which is a bit big, but if you download the source and take out some of the methods you will not be using, then it is not as big.
=> Good thing about it is that it will handle badly formed HTML
Here's a good example from their site.
We all know that programming have endless possibilities.There are numbers of solutions available for a single problem so i think all of the above solutions are perfect and may be helpful for someone but for me this one save my day..
So Code goes like this
You just have to call the above function in
onCreate Method
of yourMainActivity
I hope this one is also helpful for you guys.
Also read the original blog at Medium
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.