Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

Navigating through the HTML table using code

 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Report post to moderator
Say I have a HTML table rendered onto a web page with a certain number of rows and columns. Is it possible to "navigate" through the table (i.e. to particular row-column intersections [cells]) using code? Can someone please give me a sample?

Thanks a ton!
 
Rob Spoor
Sheriff
Pie
Posts: 20532
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
The javax.swing.text.html and javax.swing.text.html.parser packages can help you out a bit.

Basically, you'll need a parser, and a callback to handle what you encounter:
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Report post to moderator
This may get thrown out of the beginner forum, but for a real mind blower, see the Parse class in the FIT testing tool. It parses an HTML table into a graph of objects in only a few lines.
 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Report post to moderator
I had no idea how difficult this is to do with Java. I have to do this in a web application using JSP.

What is the FIT testing tool? I am totally uninitiated!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64851
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Report post to moderator
So I take it you are doing some screen scraping? Cannot you negotiate with your data provider to get the information in a more digestible format? HTML is a display format so it's not surprising that it's difficult to try and use it as a data format.
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Report post to moderator
as predicted, this is SO getting thrown out of the beginner's forum
 
Sridhar Venkataraman
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for the move and the replies..

I actually have asked this question because it is the only idea I got in my head in relation to solving the *big* dilemma I posted here. Any help there will be appreciated whole-heartedly!

http://www.coderanch.com/t/292896/JSP/java/Seating-arrangement-application-JSP-Struts
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Report post to moderator
I followed up in the other thread. I think you need to generate HTML, not parse it. Does that sound right?
 
    Bookmark Topic Watch Topic
  • New Topic