Package org.htmlparser.tags

Examples of org.htmlparser.tags.Html


    protected void setUp() throws Exception {
        super.setUp();
        createParser(prefix + tag1 + tag2 + tag3 + tag4 + suffix);
        parseAndAssertNodeCount(1);
        assertTrue("Only node should be an HTML node",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML node should have one child",1 == html.getChildCount ());
        assertTrue("Only node should be an HEAD node",html.getChild(0) instanceof HeadTag);
        HeadTag head = (HeadTag)html.getChild(0);
        assertTrue("HEAD node should have four children",4 == head.getChildCount ());
        assertTrue("First child should be a title tag",head.getChild(0) instanceof TitleTag);
        titleTag = (TitleTag)head.getChild(0);
    }
View Full Code Here


            "</BODY>\n"+
            "</HTML>";       
        createParser(text);
        parseAndAssertNodeCount(1);
        assertTrue ("Only node is a html tag",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertEquals ("Html node has five children", 5, html.getChildCount ());
        assertTrue ("Second child is a head tag", html.childAt (1) instanceof HeadTag);
        HeadTag head = (HeadTag)html.childAt (1);
        assertEquals ("Head node has two children", 2, head.getChildCount ());
        assertTrue ("Second child is a title tag", head.childAt (1) instanceof TitleTag);
        TitleTag titleTag = (TitleTag)head.childAt (1);
        assertEquals("Title","SISTEMA TERRA, VOL. VI , No. 1-3, December 1997",titleTag.getTitle());
// Note: this will fail because of the extra > inserted to finish the /TITLE tag:
View Full Code Here

            "<a href=\"home.cfm\">Home</a>\n"+
            "...\n"+
            "</html>","http://transfer.go.com");
        parseAndAssertNodeCount(1);
        assertTrue("Node 1 should be a HTML tag", node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("Html tag should have 2 children", 2 == html.getChildCount ());
        assertTrue("Html 2nd child should be HEAD tag", html.getChild (1) instanceof HeadTag);
        HeadTag head = (HeadTag)html.getChild (1);
        assertTrue("Head tag should have 7 children", 7 == head.getChildCount ());
        assertTrue("Head 6th child should be a link tag", head.getChild (5) instanceof LinkTag);
        LinkTag linkTag = (LinkTag)head.getChild (5);
        assertEquals("Resolved Link","http://www.abc.com/home.cfm",linkTag.getLink());
        assertEquals("Resolved Link Text","Home",linkTag.getLinkText());
View Full Code Here

        "<META name=\"language\" content=\"en\">\n"+
        "<META name=\"owner\" content=\"service@admin.spamcop.net\">\n"+
        "<META HTTP-EQUIV=\"content-type\" CONTENT=\"text/html; charset=ISO-8859-1\">");
        parseAndAssertNodeCount(3);
        assertTrue("Third node should be an HTML node",node[2] instanceof Html);
        Html html = (Html)node[2];
        assertTrue("HTML node should have two children",2 == html.getChildCount ());
        assertTrue("Second node should be an HEAD node",html.getChild(1) instanceof HeadTag);
        HeadTag head = (HeadTag)html.getChild(1);
        assertTrue("HEAD node should have eleven children",11 == head.getChildCount ());
        assertTrue("Third child should be a title tag",head.getChild(2) instanceof MetaTag);
        MetaTag metaTag = (MetaTag)head.getChild(2);
        assertStringEquals("Meta Tag Name",description,metaTag.getMetaTagName());
        assertStringEquals("Meta Tag Contents",content,metaTag.getMetaContent());
View Full Code Here

    public void testScanBug() throws ParserException {
        createParser("<html><head><title>Yahoo!</title><base href=http://www.yahoo.com/ target=_top><meta http-equiv=\"PICS-Label\" content='(PICS-1.1 \"http://www.icra.org/ratingsv02.html\" l r (cz 1 lz 1 nz 1 oz 1 vz 1) gen true for \"http://www.yahoo.com\" r (cz 1 lz 1 nz 1 oz 1 vz 1) \"http://www.rsac.org/ratingsv01.html\" l r (n 0 s 0 v 0 l 0) gen true for \"http://www.yahoo.com\" r (n 0 s 0 v 0 l 0))'><style>a.h{background-color:#ffee99}</style></head>",
        "http://www.google.com/test/index.html");
        parseAndAssertNodeCount(1);
        assertTrue("First node should be a HTML tag", node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML tag should have one child", 1 == html.getChildCount ());
        assertTrue("First child should be a HEAD tag", html.childAt (0) instanceof HeadTag);
        HeadTag head = (HeadTag)html.childAt (0);
        assertTrue("HEAD tag should have four children", 4 == head.getChildCount ());
        assertTrue("Fourth child should be a STYLE tag", head.childAt (3) instanceof StyleTag);
        StyleTag styleTag = (StyleTag)head.childAt (3);
        assertEquals("Style Code","a.h{background-color:#ffee99}",styleTag.getStyleCode());
    }
View Full Code Here

        createParser("<html><head><META HTTP-EQUIV=\"content-type\" CONTENT=\"text/html; charset=ISO-8859-1\"><title>Google</title><style>"+
        expectedCode+
        "</style>","http://www.yle.fi/");
        parseAndAssertNodeCount(1);
        assertTrue("First node should be a HTML tag", node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML tag should have one child", 1 == html.getChildCount ());
        assertTrue("First child should be a HEAD tag", html.childAt (0) instanceof HeadTag);
        HeadTag head = (HeadTag)html.childAt (0);
        assertTrue("HEAD tag should have three children", 3 == head.getChildCount ());
        assertTrue("Third child should be a STYLE tag", head.childAt (2) instanceof StyleTag);
        StyleTag styleTag = (StyleTag)head.childAt (2);
        assertStringEquals("Expected Style Code",expectedCode,styleTag.getStyleCode());
    }
View Full Code Here

        Node[] nodes;

        parser = new Parser(url);
        PrototypicalNodeFactory factory = new PrototypicalNodeFactory ();
        // we want to expose the repetitive tags
        factory.unregisterTag (new Html ());
        factory.unregisterTag (new HeadTag ());
        factory.unregisterTag (new BodyTag ());
        factory.unregisterTag (new ParagraphTag ());
        parser.setNodeFactory (factory);
        i = 0;
View Full Code Here

    public void testEmptyTag3() throws ParserException {
        String testHTML = "<html><body>text<>text</body></html>";
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Only node should be an HTML node",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML node should have one child",1 == html.getChildCount ());
        assertTrue("Only node should be an BODY node",html.getChild(0) instanceof BodyTag);
        BodyTag body = (BodyTag)html.getChild(0);
        assertTrue("BODY node should have one child",1 == body.getChildCount ());
        assertTrue("Only node should be a string node",body.getChild(0) instanceof Text);
        Text stringNode = (Text)body.getChild(0);
        assertEquals("Third node has incorrect text","text<>text",stringNode.getText());
    }
View Full Code Here

    public void testEmptyTag4() throws ParserException {
        String testHTML = "<html><body>text\n<>text</body></html>";
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Only node should be an HTML node",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML node should have one child",1 == html.getChildCount ());
        assertTrue("Only node should be an BODY node",html.getChild(0) instanceof BodyTag);
        BodyTag body = (BodyTag)html.getChild(0);
        assertTrue("BODY node should have one child",1 == body.getChildCount ());
        assertTrue("Only node should be a string node",body.getChild(0) instanceof Text);
        Text stringNode = (Text)body.getChild(0);
        String actual = stringNode.getText();
        assertEquals("Third node has incorrect text","text\n<>text",actual);
View Full Code Here

    public void testEmptyTag5() throws ParserException {
        String testHTML = "<html><body>text<\n>text</body></html>";
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Only node should be an HTML node",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML node should have one child",1 == html.getChildCount ());
        assertTrue("Only node should be an BODY node",html.getChild(0) instanceof BodyTag);
        BodyTag body = (BodyTag)html.getChild(0);
        assertTrue("BODY node should have one child",1 == body.getChildCount ());
        assertTrue("Only node should be a string node",body.getChild(0) instanceof Text);
        Text stringNode = (Text)body.getChild(0);
        String actual = stringNode.getText();
        assertEquals("Third node has incorrect text","text<\n>text",actual);
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.