Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Navigating through the HTML table using code

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 22816
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Sheriff
Posts: 67752
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

https://coderanch.com/t/292896/JSP/java/Seating-arrangement-application-JSP-Struts
 
Stan James
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    Bookmark Topic Watch Topic
  • New Topic