Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Html atribute grabber

 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way of converting a String of html into a hash/map/collection of its attributes?

Thank you in advance,
D.P.
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes. I recommend looking at a good HTML parser, such as JTidy.
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the help
 
Daniel Prene
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JTidy doesn't seem to have that functionality...
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried parsing a DOM with it?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like the Quiotix Parser because it provides a slick visitor interface which I prefer over walking the DOM. I have some description of visitor and a link to Quiotix from HERE. In short, you'd parse an HTML string and write a visitor to extract any attributes you like from all the nodes.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic