Two Laptop Bag*
The moose likes Servlets and the fly likes Parse text for form elements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Parse text for form elements" Watch "Parse text for form elements" New topic
Author

Parse text for form elements

James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
I have a chunk of text which I am reading from the database which contains html. I need to pull all of the form elements from this text. Is there any cleaner way of doing this than looking for every combination of upper/lowercase form element tags? I don't want to have to look for all of these...

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Surely there is a better way to store an abstraction of these elements rather than a blob of HTML?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
James Ellis
Ranch Hand

Joined: Oct 14, 2004
Posts: 205
Hey I agree. Unfortunately this is the design that I am stuck working with and there is little to nothing I can do to change that.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60774
    
  65

Eesh! I feel your pain.

If the HTML is well-formed, you should be able to locate a 3rd party parser that could take the parsing drudgery off your hands.
dema rogatkin
Ranch Hand

Joined: Oct 09, 2002
Posts: 294
HTML parser supplied with Swing standard package works quite well. So you do not need even looking around.


Tough in space?, <a href="http://tjws.sf.net" target="_blank" rel="nofollow">Get J2EE servlet container under 150Kbytes here</a><br />Love your iPod and want it anywhere?<a href="http://mediachest.sf.net" target="_blank" rel="nofollow">Check it here.</a><br /><a href="http://7bee.j2ee.us/book/Generics%20in%20JDK%201.5.html" target="_blank" rel="nofollow">Curious about generic in Java?</a><br /><a href="http://7bee.j2ee.us/bee/index-bee.html" target="_blank" rel="nofollow">Hate ant? Use bee.</a><br /><a href="http://7bee.j2ee.us/addressbook/" target="_blank" rel="nofollow">Need contacts anywhere?</a><br /><a href="http://searchdir.sourceforge.net/" target="_blank" rel="nofollow">How to promote your business with a search engine</a>
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12760
    
    5
You might find the JTidy toolkit to be more powerful and flexible than the Swing HTML handlers.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Parse text for form elements
 
Similar Threads
File upload doesn't work when additional form elements introduced
javascript function returning undefined
need enclosing form name of a element in jquery
get all from select multiple
converting dropdown into an editable dropdown