Design question - HTML table parser

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rio

    #1

    Design question - HTML table parser

    I'm trying to build HTML table parser (available not satisfying my needs), I
    need to know what is in every cell, along with its cell, row and table
    number plus the attributes that go with those tags.

    I create Table, TableRow and TableCell objects each containing an array list
    of subelements. That works fine when the tables are not nested, so my
    question is how would I design Table that holds Rows that hold Cells which
    again can contain the whole Table!


  • Hal Rosser

    #2
    Re: Design question - HTML table parser


    "Rio" <riolino_eatbal l@yahoo.com> wrote in message
    news:col473$p0l $1@ls219.htnet. hr...[color=blue]
    > I'm trying to build HTML table parser (available not satisfying my needs),[/color]
    I[color=blue]
    > need to know what is in every cell, along with its cell, row and table
    > number plus the attributes that go with those tags.
    >
    > I create Table, TableRow and TableCell objects each containing an array[/color]
    list[color=blue]
    > of subelements. That works fine when the tables are not nested, so my
    > question is how would I design Table that holds Rows that hold Cells[/color]
    which[color=blue]
    > again can contain the whole Table!
    >
    >[/color]
    <table>
    <tr>
    <td>content</td>
    <td> <table>
    <tr>
    <td>content</td>
    <td>more content</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>


    ---
    Outgoing mail is certified Virus Free.
    Checked by AVG anti-virus system (http://www.grisoft.com).
    Version: 6.0.799 / Virus Database: 543 - Release Date: 11/19/2004


    Comment

    • Pop Qvarnström

      #3
      Re: Design question - HTML table parser

      Rio wrote:
      [color=blue]
      > I'm trying to build HTML table parser (available not satisfying my needs),
      > I need to know what is in every cell, along with its cell, row and table
      > number plus the attributes that go with those tags.
      >
      > I create Table, TableRow and TableCell objects each containing an array
      > list of subelements. That works fine when the tables are not nested, so my
      > question is how would I design Table that holds Rows that hold Cells
      > which again can contain the whole Table![/color]

      I'd suggest creating an interface TableData. Then each TableCell can contain
      TableData, and Table could implement that.

      I used something like this in an old HTML -> fixed width formatted text
      parser.

      public interface TableData {
      public String[] getText();
      }

      public class Table implements TableData {
      ....
      }

      public class TableCell {
      public TableCell(Table Data) {...}
      }

      Comment

      Working...