Package org.htmlparser

Examples of org.htmlparser.PrototypicalNodeFactory


        Node node;

        try
        {
            createParser("<body style=\"margin-top:4px; margin-left:20px;\" title=\"body\">");
            parser.setNodeFactory (new PrototypicalNodeFactory (new BodyTag ()));
            iterator = parser.elements ();
            node = null;
            while (iterator.hasMoreNodes ())
            {
                node = iterator.nextNode ();
View Full Code Here


    }

    public void testSimpleBody() throws ParserException {
        createParser("<html><head><title>Test 1</title></head><body>This is a body tag</body></html>");
        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new BodyTag (),
                    new TitleTag (),
                }));
View Full Code Here

    }

    public void testBodywithJsp() throws ParserException {
        String body = "<body><%=BodyValue%></body>";
        createParser("<html><head><title>Test 1</title></head>" + body + "</html>");
        parser.setNodeFactory (new PrototypicalNodeFactory (new BodyTag ()));
        parseAndAssertNodeCount(8);
        assertTrue(node[6] instanceof BodyTag);
        // check the body node
        BodyTag bodyTag = (BodyTag) node[6];
        assertStringEquals("Body",body,bodyTag.toHtml());
View Full Code Here

    public void testBodyMixed() throws ParserException {
        String body = "<body>before jsp<%=BodyValue%>after jsp</body>";
        createParser("<html><head><title>Test 1</title></head>" + body + "</html>");
        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new BodyTag (),
                    new TitleTag (),
                }));
View Full Code Here

    }

    public void testBodyEnding() throws ParserException {
        String body = "<body>before jsp<%=BodyValue%>after jsp";
        createParser("<html>" + body + "</html>");
        parser.setNodeFactory (new PrototypicalNodeFactory (new BodyTag ()));
        parseAndAssertNodeCount(3);
        assertTrue(node[1] instanceof BodyTag);
        // check the body node
        BodyTag bodyTag = (BodyTag) node[1];
        assertEquals("Body",body + "</body>",bodyTag.toHtml());
View Full Code Here

    public void testSimpleSearch() throws ParserException {
        createParser(
            "<SPAN>The Refactoring Challenge</SPAN>" +
            "<SPAN>&#013;id: 6</SPAN>"
        );
        parser.setNodeFactory (new PrototypicalNodeFactory (new Span ()));
        assertSpanContent(parser.extractAllNodesThatMatch (new NodeClassFilter (Span.class)).toNodeArray ());
    }
View Full Code Here

            "   <SPAN>The Refactoring Challenge</SPAN>" +
            "   <SPAN>&#013;id: 6</SPAN>" +
            "</DIV>"
        );
        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new Div (),
                    new Span (),
                }));
View Full Code Here

            "       <SPAN>&#013;id: 6</SPAN>" +
            "   </DIV>" +
            "</table>"
        );
        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new Div (),
                    new Span (),
                    new TableTag (),
View Full Code Here

    public void testImageTagsFromYahoo() throws ParserException
    {
        createParser("<small><a href=s/5926>Air</a>, <a href=s/5927>Hotel</a>, <a href=s/5928>Vacations</a>, <a href=s/5929>Cruises</a></small></td><td align=center><a href=\"http://rd.yahoo.com/M=218794.2020165.3500581.220161/D=yahoo_top/S=2716149:NP/A=1041273/?http://adfarm.mediaplex.com/ad/ck/990-1736-1039-211\" target=\"_top\"><img width=230 height=33 src=\"http://us.a1.yimg.com/us.yimg.com/a/co/columbiahouse/4for49Freesh_230x33_redx2.gif\" alt=\"\" border=0></a></td><td nowrap align=center width=215>Find your match on<br><a href=s/2734><b>Yahoo! Personals</b></a></td></tr><tr><td colspan=3 align=center><input size=30 name=p>\n"+
        "<input type=submit value=Search> <a href=r/so>advanced search</a></td></tr></table><table border=0 cellspacing=0 cellpadding=3 width=640><tr><td nowrap align=center><table border=0 cellspacing=0 cellpadding=0><tr><td><a href=s/5948><img src=\"http://us.i1.yimg.com/us.yimg.com/i/ligans/klgs/eet.gif\" width=20 height=20 border=0></a></td><td> &nbsp; &nbsp; <a href=s/1048><b>Yahooligans!</b></a> - <a href=s/5282>Eet & Ern</a>, <a href=s/5283>Games</a>, <a href=s/5284>Science</a>, <a href=s/5285>Sports</a>, <a href=s/5286>Movies</a>, <a href=s/1048>more</a> &nbsp; &nbsp; </td><td><a href=s/5948><img src=\"http://us.i1.yimg.com/us.yimg.com/i/ligans/klgs/ern.gif\" width=20 height=20 border=0></a></td></tr></table></td></tr><tr><td nowrap align=center><small><b>Shop</b>&nbsp;\n","http://www.yahoo.com");
        Node [] node = new Node[10];
        parser.setNodeFactory (new PrototypicalNodeFactory (new ImageTag ()));
        int i = 0;
        Node thisNode;
        for (NodeIterator e = parser.elements();e.hasMoreNodes();) {
            thisNode = e.nextNode();
            if (thisNode instanceof ImageTag)
View Full Code Here

            "<frame name=\"topFrame\" noresize src=\"demo_bc_top.html\" scrolling=\"NO\" frameborder=\"NO\">\n"+
            "<frame name=\"mainFrame\" src=\"http://www.kizna.com/web_e/\" scrolling=\"AUTO\">\n"+
        "</frameset>","http://www.google.com/test/index.html");

        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new FrameSetTag (),
                    new FrameTag (),
                }));
View Full Code Here

TOP

Related Classes of org.htmlparser.PrototypicalNodeFactory

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.