• Post Reply Bookmark Topic Watch Topic
  • New Topic

Which library to use parse HTML in android?  RSS feed

 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there

I am working in an application In which their is blogs section.blogs data is coming from server as a form of html tags
My question is so far I found two ways to parse HTML in android

1)Using JSoup
2)Using Html.formHtml()

which one to use and is there any other method to parse HTML in android?
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried comparing results for both using the same source?
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I am getting data from server like this

"This is my first text and it countinue  <a href="www.domainname.com">This is Link</a>.This is my second text and this text countinue"

so what I am facing problem so far is getting href value from anchor tag


I have general question what is proper way to send HTML text as JSON to android?
 
Tim Moores
Saloon Keeper
Posts: 3569
77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think a better approach would be to refactor the server code so it can send plain data rather that HTML.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That I also think because so far I didn't find any way to extract attribute value from an HTML tag
 
Tim Moores
Saloon Keeper
Posts: 3569
77
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That probably reflects the general practice of sending as little data as possible to the mobile device; that means just the raw data.

On JavaSE, HtmlUnit works very well in handling all kinds of HTML tasks, including extracting data, but last I looked at its source code, it used AWT, Swing and ImageIO classes that aren't available on Android, so porting it over to Android may not be a trivial task.
 
Kishor Joshi
Ranch Hand
Posts: 674
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Tim Moores

Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!