Menu

Parsing HTML Table Help Needed

Help
Pandu
2007-09-21
2013-04-27
  • Pandu

    Pandu - 2007-09-21

    Hello Everybody,

    I want to parse a html file which is like this

    <html>
    <head>
    </head>
    <body>
    <table>

    <table tabid='a'>
    <table tabid='maintable'>
    <tr>
    <td>111
    </td>
    <td>abc
    </td>
    <td>123
    </td>
    </tr>

    I want to parse a html file which is like this

    <html>
    <head>
    </head>
    <body>
    <table>

    <table tabid='a'>
    <table tabid='maintable'>
    <tr>
    <td>111
    </td>
    <td>abc
    </td>
    <td>123
    </td>
    </tr>

    </table>
    </table>

    <table>
    </table>

    <table>
    </table>
    </table>

    </body>
    </html>

    Now i want to take that inner table which has tabid='maintable' and i want those values which are in td tags.. How can i do that?? Any help appreciated..

    Thanks in advance
    -Pandu

     
    • Derrick Oswald

      Derrick Oswald - 2007-09-21

      You can retrieve the table you want with a filter like:

      NodeList list = parser.Parse (
        new AndFilter (
          new TagNameFilter ("TABLE"),
          new HasAttributeFilter ("tabid", "maintable")));

      Then cast each node in the list to a TableTag and use the TableTag accessors to get the rows (TableRow[] getRows ()) and from the rows get the columns (TableColumn[] getColumns ()).

       
    • Pandu

      Pandu - 2007-09-22

      Thanks for your help.. You saved my time

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.