Package org.htmlparser.tags

Examples of org.htmlparser.tags.Tag


    public void assertTagNameShouldBe(
        String message,
        Node node,
        String expectedTagName)
    {
        Tag tag = (Tag) node;
        assertStringEquals(message, expectedTagName, tag.getTagName());
    }
View Full Code Here


     * This is the reproduction of a bug which causes a null pointer exception
     */
    public void testExtractLinkInvertedCommasBug() throws ParserException
    {
        String tagContents = "a href=r/anorth/top.html";
        Tag tag = new Tag(new TagData(0, 0, tagContents, ""));
        String url = "c:\\cvs\\html\\binaries\\yahoo.htm";
        LinkScanner scanner = new LinkScanner("-l");
        assertEquals(
            "Extracted Link",
            "r/anorth/top.html",
View Full Code Here

    public void testReplaceFaultyTagWithEndTag() throws ParserException
    {
        String currentLine =
            "<p>Site Comments?<br><a href=\"mailto:sam@neurogrid.com?subject=Site Comments\">Mail Us<a></p>";
        Tag tag = new Tag(new TagData(85, 87, "a", currentLine));
        LinkScanner linkScanner = new LinkScanner();
        String newLine =
            linkScanner.replaceFaultyTagWithEndTag(tag, currentLine);
        assertEquals(
            "Expected replacement",
View Full Code Here

    }

    public void testInsertEndTagBeforeTag() throws ParserException
    {
        String currentLine = "<a href=s/7509><b>Yahoo! Movies</b></a>";
        Tag tag = new Tag(new TagData(0, 14, "a href=s/7509", currentLine));
        LinkScanner linkScanner = new LinkScanner();
        String newLine = linkScanner.insertEndTagBeforeNode(tag, currentLine);
        assertEquals(
            "Expected insertion",
            "</A><a href=s/7509><b>Yahoo! Movies</b></a>",
View Full Code Here

        // Register the image scanner
        parser.addScanner(new LinkScanner("-l"));

        parseAndAssertNodeCount(3);
        assertTrue("Node 0 should be a tag", node[0] instanceof Tag);
        Tag tag = (Tag) node[0];
        assertEquals("Tag Contents", "a", tag.getText());
        assertTrue(
            "Node 1 should be a string node",
            node[1] instanceof StringNode);
        StringNode stringNode = (StringNode) node[1];
        assertEquals("StringNode Contents", "Revision", stringNode.getText());
View Full Code Here

            "See Signs in Theaters 8-2 - Starring Mel Gibson",
            imageTag.getAttribute("ALT"));
        assertTrue(
            "Second contained node should be Tag",
            containedNodes[1] instanceof Tag);
        Tag tag1 = (Tag) containedNodes[1];
        assertEquals(
            "Tag Contents",
            "font face=\"verdana,arial,helvetica\" SIZE=\"1\"",
            tag1.getText());
        assertTrue(
            "Third contained node should be Tag",
            containedNodes[2] instanceof Tag);
        Tag tag2 = (Tag) containedNodes[2];
        assertEquals("Tag Contents", "b", tag2.getText());
        assertTrue(
            "Fourth contained node should be HTMLEndTag",
            containedNodes[3] instanceof EndTag);
        EndTag endTag1 = (EndTag) containedNodes[3];
        assertEquals("Fourth Tag contents", "b", endTag1.getText());
View Full Code Here

        parser.registerScanners();
        parseAndAssertNodeCount(1);
        // Check the tags
        assertType("node", Div.class, node[0]);
        Div div = (Div) node[0];
        Tag fontTag = (Tag) div.children().nextNode();
        assertEquals(
            "Second tag should be corrected",
            "font face=\"Arial,helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\"",
            fontTag.getText());
        // Try to parse the parameters from this tag.
        Hashtable table = fontTag.getAttributes();
        assertNotNull("Parameters table", table);
        assertEquals(
            "font sans-serif parameter",
            "sans-serif",
            table.get("SANS-SERIF"));
View Full Code Here

                    + "<A HREF=\"Hello.html\">Hey</A>");
        createParser(testHTML);
        parseAndAssertNodeCount(7);
        // The node should be an Tag
        assertTrue("1st Node should be a Tag", node[0] instanceof Tag);
        Tag tag = (Tag) node[0];
        assertStringEquals(
            "toHTML()",
            "<MYTAG EFGH=\"\" ABCD=\"\" MNOP=\"\" IJKL=\"\">",
            tag.toHtml());
        assertTrue("2nd Node should be a Tag", node[1] instanceof Tag);
        assertTrue("5th Node should be a Tag", node[4] instanceof Tag);
        tag = (Tag) node[1];
        assertEquals("Raw String of the tag", "<TITLE>", tag.toHtml());
        tag = (Tag) node[4];
        assertEquals(
            "Raw String of the tag",
            "<A HREF=\"Hello.html\">",
            tag.toHtml());
    }
View Full Code Here

     * Created by Kaarle Kaila (22 Oct 2001)
     * This test just wants the text in the element
     */
    public void testWithoutParseParameter() throws ParserException
    {
        Tag tag;
        EndTag etag;
        StringNode snode;
        Node node = null;
        String testHTML =
            "<A href=\"http://www.iki.fi/kaila\" myParameter yourParameter=\"Kaarle\">Kaarle's homepage</A><p>Paragraph</p>";
View Full Code Here

    * Created by Kaarle Kaila (09 Jan 2003)
    * This test just wants the text in the element
    */
    public void testEmptyTagParseParameter() throws ParserException
    {
        Tag tag;
        EndTag etag;
        StringNode snode;
        Node node = null;
        String testHTML =
            "<INPUT name=\"foo\" value=\"foobar\" type=\"text\" />";
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.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.