Package org.htmlparser.tags

Examples of org.htmlparser.tags.Html


    public void testEmptyTag6() throws ParserException {
        String testHTML = "<html><body>text<>\ntext</body></html>";
        createParser(testHTML);
        parseAndAssertNodeCount(1);
        assertTrue("Only node should be an HTML node",node[0] instanceof Html);
        Html html = (Html)node[0];
        assertTrue("HTML node should have one child",1 == html.getChildCount ());
        assertTrue("Only node should be an BODY node",html.getChild(0) instanceof BodyTag);
        BodyTag body = (BodyTag)html.getChild(0);
        assertTrue("BODY node should have one child",1 == body.getChildCount ());
        assertTrue("Only node should be a string node",body.getChild(0) instanceof Text);
        Text stringNode = (Text)body.getChild(0);
        String actual = stringNode.getText();
        assertEquals("Third node has incorrect text","text<>\ntext",actual);
View Full Code Here


        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new TitleTag (),
                    new Html (),
                }));
        parseAndAssertNodeCount(1);
        assertType("html tag",Html.class,node[0]);
        Html html = (Html)node[0];
        NodeList nodeList = new NodeList();
        NodeClassFilter filter = new NodeClassFilter (TitleTag.class);
        html.collectInto(nodeList, filter);
        assertEquals("nodelist size",1,nodeList.size());
        Node node = nodeList.elementAt(0);
        assertType("expected title tag",TitleTag.class,node);
        TitleTag titleTag = (TitleTag)node;
        assertStringEquals("title","Some Title",titleTag.getTitle());
View Full Code Here

        + "  </body>" + "</html>");
    parser.addScanner(new TitleScanner(""));
    parser.addScanner(new HtmlScanner());
    parseAndAssertNodeCount(1);
    assertType("html tag", Html.class, node[0]);
    Html html = (Html) node[0];
    NodeList nodeList = new NodeList();
    html.collectInto(nodeList, TitleTag.class);
    assertEquals("nodelist size", 1, nodeList.size());
    Node node = nodeList.elementAt(0);
    assertType("expected title tag", TitleTag.class, node);
    TitleTag titleTag = (TitleTag) node;
    assertStringEquals("title", "Some Title", titleTag.getTitle());
View Full Code Here

  public String[] getID() {
    return MATCH_STRING;
  }

  public Tag createTag(TagData tagData, CompositeTagData compositeTagData) {
    return new Html(tagData, compositeTagData);
  }
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.Html

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.