This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Html atribute grabber Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Html atribute grabber" Watch "Html atribute grabber" New topic
Author

Html atribute grabber

Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
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

Joined: May 22, 2003
Posts: 657

Yes. I recommend looking at a good HTML parser, such as JTidy.
Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
Thank you for the help
Daniel Prene
Ranch Hand

Joined: Jul 15, 2005
Posts: 241
JTidy doesn't seem to have that functionality...
Steve Morrow
Ranch Hand

Joined: May 22, 2003
Posts: 657

Have you tried parsing a DOM with it?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Html atribute grabber
 
Similar Threads
Default Body Content
Formatting in XML
Simple question concerning dates, JSP and Javabeans
How To Set All the Textfields in a Web Page to READONLY?
Using color in a pane