Package org.htmlparser.tags

Examples of org.htmlparser.tags.Tag


    {
        String testHTML1 = new String("<link rel src=\"af.css\"/>");
        createParser(testHTML1, "http://www.google.com/test/index.html");
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a tag", node[0] instanceof Tag);
        Tag tag = (Tag) node[0];
        assertEquals("StyleSheet Source", "af.css", tag.getAttribute("src"));
    }
View Full Code Here


    {
        String testHTML1 = new String("<br");
        createParser(testHTML1);
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a tag", node[0] instanceof Tag);
        Tag tag = (Tag) node[0];
        assertEquals("Node contents", "br", tag.getText());
    }
View Full Code Here

        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 testHTML =
            new String("<META NAME=\"Author\" CONTENT = \"DORIER-APPRILL E., GERVAIS-LAMBONY P., MORICONI-EBRARD F., NAVEZ-BOUCHANINE F.\"\">");
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Node should be a tag", node[0] instanceof Tag);
        Tag tag = (Tag) node[0];
        assertStringEquals(
            "Node contents",
            "META NAME=\"Author\" CONTENT=\"DORIER-APPRILL E., GERVAIS-LAMBONY P., MORICONI-EBRARD F., NAVEZ-BOUCHANINE F.\"",
            tag.getText());
        Hashtable table = tag.getAttributes();
        assertEquals(
            "Meta Content",
            "DORIER-APPRILL E., GERVAIS-LAMBONY P., MORICONI-EBRARD F., NAVEZ-BOUCHANINE F.",
            tag.getAttribute("CONTENT"));

    }
View Full Code Here

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

        String testHTML =
            new String("<meta name=\"description\" content=\"Une base de donn�es sur les th�ses 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�es sur les th�ses de gographie soutenues en France\"",
            tag.getText());
    }
View Full Code Here

    {
        String testHTML = "<TEXTAREA name=\"JohnDoe\" ></TEXTAREA>";
        createParser(testHTML);
        parseAndAssertNodeCount(2);
        assertTrue("First node should be an HTMLtag", node[0] instanceof Tag);
        Tag htmlTag = (Tag) node[0];
        String expectedHTML = "<TEXTAREA NAME=\"JohnDoe\">";
        assertStringEquals("Expected HTML", expectedHTML, htmlTag.toHtml());
    }
View Full Code Here

            "<A \n"
                + "HREF=\"/a?b=c>d&e=f&g=h&i=http://localhost/Testing/Report1.html\">20020702 Report 1</A>";
        createParser(testHTML);
        Node node = Tag.find(parser.getReader(), testHTML, 0);
        assertTrue("Node should be a tag", node instanceof Tag);
        Tag tag = (Tag) node;
        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>");
        parseAndAssertNodeCount(1);
        // the node should be an HTMLTag
        assertTrue("Node should be a HTMLTag", node[0] instanceof Tag);
        Tag tag = (Tag) node[0];
        assertEquals("Initial text should be", "TABLE BORDER=0", tag.getText());

        Hashtable tempHash = tag.getAttributes();
        tempHash.put("BORDER", "1");
        tag.setAttributes(tempHash);

        String s = tag.toHtml();
        assertEquals("HTML should be", "<TABLE BORDER=\"1\" >", s);
    }
View Full Code Here

    public void testTagExtraction()
    {
        String testHTML =
            "<AREA \n coords=0,0,52,52 href=\"http://www.yahoo.com/r/c1\" shape=RECT>";
        createParser(testHTML);
        Tag tag = Tag.find(parser.getReader(), testHTML, 0);
        assertNotNull(tag);
    }
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.