Package org.htmlparser.tags

Examples of org.htmlparser.tags.TableTag


            + "</tr>\n"
            + "</table>";
        createParser (html);
        parseAndAssertNodeCount (1);
        assertType ("table", TableTag.class, node[0]);
        TableTag table = (TableTag)node[0];
        assertTrue ("table should have 3 nodes", 3 == table.getChildCount ());
        assertType ("row", TableRow.class, table.childAt (1));
        TableRow row = (TableRow)table.childAt (1);
        assertTrue ("row should have 3 nodes", 3 == row.getChildCount ());
        assertType ("column", TableColumn.class, row.childAt (1));
        TableColumn column = (TableColumn)row.childAt (1);
        assertTrue ("column should have 1 node", 1 == column.getChildCount ());
        assertType ("element", Div.class, column.childAt (0));
View Full Code Here


    public void testScan() throws ParserException
    {
        createParser(createHtmlWithTable());
        parseAndAssertNodeCount(1);
        assertTrue(node[0] instanceof TableTag);
        TableTag tableTag = (TableTag)node[0];
        assertEquals("rows",1,tableTag.getRowCount());
        TableRow row = tableTag.getRow(0);
        assertEquals("columns in row 1",2,row.getColumnCount());
        assertEquals("table width","100.0%",tableTag.getAttribute("WIDTH"));
    }
View Full Code Here

        parseAndAssertNodeCount(1);
        assertType("only tag should be a HTML tag", Html.class,node[0]);
        Html html = (Html)node[0];
        assertEquals("html tag should have 4 children", 4, html.getChildCount ());
        assertType("second tag",TableTag.class,html.getChild (1));
        TableTag table = (TableTag)html.getChild (1);
        assertEquals("rows",3,table.getRowCount());
        TableRow tr = table.getRow(2);
        assertEquals("columns",1,tr.getColumnCount());
        TableColumn td = tr.getColumns()[0];
        Node node = td.childAt(1);
        assertType("node",TableTag.class,node);
        TableTag table2 = (TableTag)node;
        assertEquals("second table row count",1,table2.getRowCount());
        tr = table2.getRow(0);
        assertEquals("second table col count",2,tr.getColumnCount());
    }
View Full Code Here

            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new Div (),
                    new Span (),
                    new TableTag (),
                }));
        parseAndAssertNodeCount(1);
        TableTag tableTag = (TableTag)node[0];
        Node[] spans = ParserUtils.findTypeInNode (tableTag, Span.class);
        assertSpanContent(spans);
    }
View Full Code Here

                    new InputTag (),
                    new TextareaTag (),
                    new SelectTag (),
                    new OptionTag (),
                    new LinkTag (),
                    new TableTag (),
                }));
        parseAndAssertNodeCount(1);
        assertTrue("Should be a HTMLFormTag",node[0] instanceof FormTag);
        NodeList linkTags = new NodeList ();
        NodeClassFilter filter = new NodeClassFilter (LinkTag.class);
View Full Code Here

                    new FormTag (),
                    new InputTag (),
                    new TextareaTag (),
                    new SelectTag (),
                    new OptionTag (),
                    new TableTag (),
                }));
        parseAndAssertNodeCount(1);
        assertTrue("Should be a HTMLFormTag",node[0] instanceof FormTag);
        NodeList remarkNodes = new NodeList ();
        NodeClassFilter filter = new NodeClassFilter (Remark.class);
View Full Code Here

   
    public void testScan() throws ParserException {
        createParser("<table><div align=\"left\">some text</div></table>");
        parseAndAssertNodeCount(1);
        assertType("node should be table",TableTag.class,node[0]);
        TableTag tableTag = (TableTag)node[0];
        Div div = (Div)tableTag.searchFor(Div.class, true).toNodeArray()[0];
        assertEquals("div contents","some text",div.toPlainTextString());
    }
View Full Code Here

    parser.registerScanners();
    parser.addScanner(new TableScanner(parser));
    parser.addScanner(new DivScanner());
    parseAndAssertNodeCount(1);
    assertType("node should be table", TableTag.class, node[0]);
    TableTag tableTag = (TableTag) node[0];
    Div div = (Div) tableTag.searchFor(Div.class).toNodeArray()[0];
    assertEquals("div contents", "some text", div.toPlainTextString());
  }
View Full Code Here

        + "<table border>\n" + "<tr>\n" + "<td>table2 Head1</td>\n" + "<td>table2 Val1</td>\n" + "</tr>\n"
        + "</table>\n" + "</td>\n" + "</tr>\n" + "</BODY>\n" + "</HTML>");
    parser.registerScanners();
    parseAndAssertNodeCount(4);
    assertType("second tag", TableTag.class, node[1]);
    TableTag table = (TableTag) node[1];
    assertEquals("rows", 3, table.getRowCount());
    TableRow tr = table.getRow(2);
    assertEquals("columns", 1, tr.getColumnCount());
    TableColumn td = tr.getColumns()[0];
    Node node = td.childAt(0);
    assertType("node", TableTag.class, node);
    TableTag table2 = (TableTag) node;
    assertEquals("second table row count", 1, table2.getRowCount());
    tr = table2.getRow(0);
    assertEquals("second table col count", 2, tr.getColumnCount());
  }
View Full Code Here

    parser.visitAllNodesWith(page);
    NodeList bodyNodes = page.getBody();
    assertEquals("number of nodes in body", 2, bodyNodes.size());
    assertXmlEquals("body html", "Welcome to HTMLParser" + "<table>" + "<tr>" + "  <td>cell 1</td>"
        + "  <td>cell 2</td>" + "</tr>" + "</table>", bodyNodes.asHtml());
    TableTag tables[] = page.getTables();
    assertEquals("number of tables", 1, tables.length);
    assertEquals("number of rows", 1, tables[0].getRowCount());
    TableRow row = tables[0].getRow(0);
    assertEquals("number of columns", 2, row.getColumnCount());
    TableColumn[] col = row.getColumns();
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.TableTag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.