Package org.htmlparser

Examples of org.htmlparser.Tag


    public void testTagInsideTag() throws ParserException {
        String testHTML = new String("<META name=\"Hello\" value=\"World </I>\">");
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a tag",node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertEquals("Node contents","META name=\"Hello\" value=\"World </I>\"",tag.getText());
        assertEquals("Meta Content","World </I>",tag.getAttribute("value"));

    }
View Full Code Here


        String guts = "META NAME=\"" + author + "\" CONTENT = \"" + content + "\"";
        String testHTML = "<" + guts + ">";
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a tag",node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertStringEquals("Node contents",guts,tag.getText());
        assertEquals("Meta Content",author,tag.getAttribute("NAME"));
       
        //
        // Big todo here:
        // This involves a change in the lexer state machine from
        // six states to probably 8, or perhaps a half dozen 'substates'
View Full Code Here

        String guts = "META NAME=\"Keywords\" CONTENT=Moscou, modernisation, politique urbaine, sp\u00e9cificit\u00e9s culturelles, municipalit\u00e9, Moscou, modernisation, urban politics, cultural specificities, municipality\"";
        String testHTML = "<" + guts + ">";
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a tag",node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertStringEquals("Node contents",guts,tag.getText());
    }
View Full Code Here

    public void testIncorrectInvertedCommas3() throws ParserException {
        String testHTML = new String("<meta name=\"description\" content=\"Une base de donn\u00e9es sur les th\u00e8ses de g\"ographie soutenues en France \">");
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a tag",node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        assertEquals("Node contents","meta name=\"description\" content=\"Une base de donn\u00e9es sur les th\u00e8ses de g\"ographie soutenues en France \"",tag.getText());
    }
View Full Code Here

        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

        String testHTML = "<A \n"+
        "HREF=\"/a?b=c>d&e=f&g=h&i=http://localhost/Testing/Report1.html\">20020702 Report 1</A>";
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a tag",node[0] instanceof Tag);
        Tag tag = (Tag)node[0];
        String href = tag.getAttribute("HREF");
        assertStringEquals("Resolved Link","/a?b=c>d&e=f&g=h&i=http://localhost/Testing/Report1.html",href);
    }
View Full Code Here

        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 ());
        tag.setAttribute ("BORDER","\"1\"");
        assertEquals("HTML should be","<TABLE BORDER=\"1\">", tag.toHtml ());
    }
View Full Code Here

        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(
            "html",
            testHtml,
            tag.toHtml()
        );
    }
View Full Code Here

        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());
        assertStringEquals(
            "html",
            html,
            tag.toHtml()
        );
    }
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

TOP

Related Classes of org.htmlparser.Tag

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.