Package org.htmlparser

Examples of org.htmlparser.PrototypicalNodeFactory


            "<a href=\"http://www.yahoo.com/\">Yahoo!</a><br>" +
            "<a href=\"http://www.excite.com\">Excite</a>" +
            "</body>" +
            "</html>"
        );
        parser.setNodeFactory (new PrototypicalNodeFactory (
            new Tag[] {
                new MetaTag (),
                new TitleTag (),
                new LinkTag (),
            }));
View Full Code Here


        String testHTML = tag1 +
            "\n"+
            "<TITLE>Hello</TITLE>\n"+
            "<A HREF=\"Hello.html\">Hey</A>";
        createParser(testHTML);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(9);
        // The node should be an Tag
        assertTrue("1st Node should be a Tag",node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertStringEquals("toHTML()",tag1,tag.toHtml());
View Full Code Here

     * Ignore empty tags.
     */
    public void testEmptyTag() throws ParserException {
        String testHTML = "<html><body><>text</body></html>";
        createParser(testHTML);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(5);
        assertTrue("Third node should be a string node",node[2] instanceof Text);
        Text stringNode = (Text)node[2];
        assertEquals("Third node has incorrect text","<>text",stringNode.getText());
    }
View Full Code Here

     * Ignore empty tags.
     */
    public void testEmptyTag2() throws ParserException {
        String testHTML = "<html><body>text<></body></html>";
        createParser(testHTML);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(5);
        assertTrue("Third node should be a string node",node[2] instanceof Text);
        Text stringNode = (Text)node[2];
        assertEquals("Third node has incorrect text","text<>",stringNode.getText());
    }
View Full Code Here

    public void testAttributesReconstruction() throws ParserException {
        String expectedHTML = "<TEXTAREA name=\"JohnDoe\" >";
        String testHTML = expectedHTML + "</TEXTAREA>";
        createParser(testHTML);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(2);
        assertTrue("First node should be an HTMLtag",node[0] instanceof Tag);
        Tag htmlTag = (Tag)node[0];
        assertStringEquals("Expected HTML",expectedHTML,htmlTag.toHtml());
    }
View Full Code Here

     * See bug #740411 setParsed() has no effect on output.
     */
    public void testParameterChange() throws ParserException
    {
        createParser("<TABLE BORDER=0>");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        // the node should be a Tag
        assertTrue("Node should be a Tag",node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertEquals("Initial text should be","TABLE BORDER=0",tag.getText ());
View Full Code Here

    public void testTagWithQuotes() throws Exception {
        String testHtml =
        "<img src=\"http://g-images.amazon.com/images/G/01/merchants/logos/marshall-fields-logo-20.gif\" width=87 height=20 border=0 alt=\"Marshall Field's\">";

        createParser(testHtml);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertType("should be Tag",Tag.class,node[0]);
        Tag tag = (Tag)node[0];
        assertStringEquals("alt","Marshall Field's",tag.getAttribute("ALT"));
        assertStringEquals(
View Full Code Here

    public void testEmptyTag() throws Exception
    {
        String html = "<custom/>";
        createParser(html);
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertType("should be Tag",Tag.class,node[0]);
        Tag tag = (Tag)node[0];
        assertStringEquals("tag name","CUSTOM",tag.getTagName());
        assertTrue("empty tag",tag.isEmptyXmlTag());
View Full Code Here

        );
    }

    public void testTagWithCloseTagSymbolInAttribute() throws ParserException {
        createParser("<tag att=\"a>b\">");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertType("should be Tag",Tag.class,node[0]);
        Tag tag = (Tag)node[0];
        assertStringEquals("attribute","a>b",tag.getAttribute("att"));
    }
View Full Code Here

        assertStringEquals("attribute","a>b",tag.getAttribute("att"));
    }

    public void testTagWithOpenTagSymbolInAttribute() throws ParserException {
        createParser("<tag att=\"a<b\">");
        parser.setNodeFactory (new PrototypicalNodeFactory (true));
        parseAndAssertNodeCount(1);
        assertType("should be Tag",Tag.class,node[0]);
        Tag tag = (Tag)node[0];
        assertStringEquals("attribute","a<b",tag.getAttribute("att"));
    }
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.