Package org.htmlparser.tags

Examples of org.htmlparser.tags.Html


                + "</html>");
        parser.addScanner(new TitleScanner(""));
        parser.addScanner(new HtmlScanner());
        parseAndAssertNodeCount(1);
        assertType("html tag", Html.class, node[0]);
        Html html = (Html) node[0];
        NodeList nodeList = new NodeList();
        html.collectInto(nodeList, TitleTag.class);
        assertEquals("nodelist size", 1, nodeList.size());
        Node node = nodeList.elementAt(0);
        assertType("expected title tag", TitleTag.class, node);
        TitleTag titleTag = (TitleTag) node;
        assertStringEquals("title", "Some Title", titleTag.getTitle());
View Full Code Here


        return MATCH_STRING;
    }

    public Tag createTag(TagData tagData, CompositeTagData compositeTagData)
    {
        return new Html(tagData, compositeTagData);
    }
View Full Code Here

     */
    public HtmlTreeModel (NodeList root)
    {
        mTreeListeners = new Vector ();
        // for simplicity we encapsulate the nodelist in a Html tag
        mRoot = new Html ();
        mRoot.setChildren (root);
    }   
View Full Code Here

        registerTag (new TitleTag ());
        registerTag (new Div ());
        registerTag (new Span ());
        registerTag (new BodyTag ());
        registerTag (new HeadTag ());
        registerTag (new Html ());
       

        return (this);
    }
View Full Code Here

            "</body>" +
            "</html>"
        );
        parseAndAssertNodeCount(2);
        assertTrue(node[1] instanceof Html);
        Html htmlTag = (Html)node[1];
        assertTrue("The HTML tag should have 3 nodes", 3 == htmlTag.getChildCount ());
        assertTrue("The first child should be a HEAD tag",htmlTag.getChild(0) instanceof HeadTag);
        HeadTag headTag = (HeadTag)htmlTag.getChild(0);
        assertTrue("The HEAD tag should have 2 nodes", 2 == headTag.getChildCount ());
        assertTrue("The second child should be a META tag",headTag.getChild(1) instanceof MetaTag);
        MetaTag metaTag = (MetaTag)headTag.getChild(1);

        assertStringEquals(
View Full Code Here

    protected void setUp() throws Exception {
        super.setUp();
        createParser("<html><head><title>body tag test</title></head>" + html + "</html>");
        parseAndAssertNodeCount(1);
        assertTrue("Only node should be an HTML node",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML node should have two children",2 == html.getChildCount ());
        assertTrue("Second node should be an BODY tag",html.getChild(1) instanceof BodyTag);
        bodyTag = (BodyTag)html.getChild(1);
    }
View Full Code Here

   
    public void testSimpleHead() throws ParserException {
        createParser("<HTML><HEAD></HEAD></HTML>");
        parseAndAssertNodeCount(1);
        assertTrue(node[0] instanceof Html);
        Html htmlTag = (Html)node[0];
        assertTrue(htmlTag.getChild(0) instanceof HeadTag);
    }
View Full Code Here

    public void testSimpleHeadWithoutEndTag() throws ParserException {
        createParser("<HTML><HEAD></HTML>");
        parseAndAssertNodeCount(1);
        assertTrue(node[0] instanceof Html);
        Html htmlTag = (Html)node[0];
        assertTrue(htmlTag.getChild(0) instanceof HeadTag);
        HeadTag headTag = (HeadTag)htmlTag.getChild(0);
        assertEquals("toHtml()","<HEAD></HEAD>",headTag.toHtml());
        assertEquals("toHtml()","<HTML><HEAD></HEAD></HTML>",htmlTag.toHtml());
    }
View Full Code Here

    public void testSimpleHeadWithBody() throws ParserException {
        createParser("<HTML><HEAD><BODY></HTML>");
        parseAndAssertNodeCount(1);
        assertTrue(node[0] instanceof Html);
        Html htmlTag = (Html)node[0];
        assertTrue(htmlTag.getChild(0) instanceof HeadTag);
        //assertTrue(htmlTag.getChild(1) instanceof BodyTag);
        HeadTag headTag = (HeadTag)htmlTag.getChild(0);
        assertEquals("toHtml()","<HEAD></HEAD>",headTag.toHtml());
        assertEquals("toHtml()","<HTML><HEAD></HEAD><BODY></BODY></HTML>",htmlTag.toHtml());
    }
View Full Code Here

            "</BODY>\n"+
            "</HTML>"
        );
        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);
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.Html

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.