Package org.htmlparser.tags

Examples of org.htmlparser.tags.LinkTag


     */
    public void testTagCharsInText() throws ParserException {
        createParser("<a href=\"http://asgard.ch\">[> ASGARD <]</a>");
        parseAndAssertNodeCount(1);
        assertTrue("Node identified must be a link tag",node[0] instanceof LinkTag);
        LinkTag linkTag = (LinkTag) node[0];
        assertEquals("[> ASGARD <]",linkTag.getLinkText());
        assertEquals("http://asgard.ch",linkTag.getLink());
    }
View Full Code Here


            }
            else if (node instanceof LinkTag)
            {
                // Node is a link
                // Cast it to an HTMLLinkTag
                LinkTag linkNode = (LinkTag)node;
                // Retrieve the data from the object and print it
                buffer.append (linkNode.getLinkText ());
            }
            else if (node instanceof Tag)
            {
                String name = ((Tag)node).getTagName ();
                if (name.equals ("BR") || name.equals ("P"))
View Full Code Here

            + "</map>"
            + "</a>";
        createParser (html);
        parseAndAssertNodeCount (1);
        assertTrue ("Node should be a LinkTag", node[0] instanceof LinkTag);
        LinkTag link = (LinkTag)node[0];
        ImageTag img = extractLinkImage (link);
        assertNotNull ("no image tag", img);
    }
View Full Code Here

        assertType("first node type",TableRow.class,node[0]);
        TableRow row = (TableRow)node[0];
        TableColumn col = row.getColumns()[1];
        Node node = col.children().nextNode();
        assertType("Node identified should be HTMLLinkTag",LinkTag.class,node);
        LinkTag linkTag = (LinkTag)node;
        Node nodeInsideLink = linkTag.children().nextNode();
        assertType("Tag within link should be an image tag",ImageTag.class,nodeInsideLink);
        ImageTag imageTag = (ImageTag)nodeInsideLink;
        assertStringEquals(
            "Expected Image",
            "http://us.a1.yimg.com/us.yimg.com/a/co/columbiahouse/4for49Freesh_230x33_redx2.gif",
View Full Code Here

        html = "<html>" + guts + "</html>";
        createParser (html);
        list = parser.extractAllNodesThatMatch (new HasChildFilter (new TagNameFilter ("b")));
        assertEquals ("only one element", 1, list.size ());
        assertType ("should be LinkTag", LinkTag.class, list.elementAt (0));
        LinkTag link = (LinkTag)list.elementAt (0);
        assertEquals ("three children", 3, link.getChildCount ());
        assertSuperType ("should be TagNode", Tag.class, link.getChildren ().elementAt (0));
        Tag tag = (Tag)link.getChildren ().elementAt (0);
        assertStringEquals("name", "B", tag.getTagName ());
    }
View Full Code Here

        html = "<html>" + guts + "</html>";
        createParser (html);
        list = parser.extractAllNodesThatMatch (new HasAttributeFilter ("id"));
        assertEquals ("only one element", 1, list.size ());
        assertType ("should be LinkTag", LinkTag.class, list.elementAt (0));
        LinkTag link = (LinkTag)list.elementAt (0);
        assertEquals ("attribute value", "target", link.getAttribute ("id"));
    }
View Full Code Here

                new HasChildFilter (
                    new StringFilter ("men")))
                );
        assertEquals ("only one element", 1, list.size ());
        assertType ("should be LinkTag", LinkTag.class, list.elementAt (0));
        LinkTag link = (LinkTag)list.elementAt (0);
        assertEquals ("attribute value", "two", link.getAttribute ("id"));
    }
View Full Code Here

                new HasChildFilter (
                    new StringFilter ("men")))
                );
        assertEquals ("two elements", 2, list.size ());
        assertType ("should be LinkTag", LinkTag.class, list.elementAt (0));
        LinkTag link = (LinkTag)list.elementAt (0);
        assertEquals ("attribute value", "one", link.getAttribute ("id"));
        assertType ("should be LinkTag", LinkTag.class, list.elementAt (1));
        link = (LinkTag)list.elementAt (1);
        assertEquals ("attribute value", "three", link.getAttribute ("id"));
    }
View Full Code Here

                    new HasChildFilter (
                        new StringFilter ("all"))))
                );
        assertEquals ("two elements", 2, list.size ());
        assertType ("should be LinkTag", LinkTag.class, list.elementAt (0));
        LinkTag link = (LinkTag)list.elementAt (0);
        assertEquals ("attribute value", "one", link.getAttribute ("id"));
        assertType ("should be LinkTag", LinkTag.class, list.elementAt (1));
        link = (LinkTag)list.elementAt (1);
        assertEquals ("attribute value", "three", link.getAttribute ("id"));
    }
View Full Code Here

        assertTrue ("column should have 1 node", 1 == column.getChildCount ());
        assertType ("element", Div.class, column.childAt (0));
        Div div = (Div)column.childAt (0);
        assertTrue ("div should have 3 nodes", 3 == div.getChildCount ());
        assertType ("link", LinkTag.class, div.childAt (1));
        LinkTag link = (LinkTag)div.childAt (1);
        assertTrue ("link contents", link.getLink ().equals ("http://www.nba.com/heat/"));
        assertType ("bogus div", Div.class, div.childAt (2));
        assertTrue ("bogus div should have no children", 0 == ((Div)div.childAt (2)).getChildCount ());
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.LinkTag

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.