Package org.htmlparser.tags

Examples of org.htmlparser.tags.TitleTag


        createParser("<html><head><title>Yahoo!</title><base href=http://www.yahoo.com/ target=_top><meta http-equiv=\"PICS-Label\" content='(PICS-1.1 \"http://www.icra.org/ratingsv02.html\" l r (cz 1 lz 1 nz 1 oz 1 vz 1) gen true for \"http://www.yahoo.com\" r (cz 1 lz 1 nz 1 oz 1 vz 1) \"http://www.rsac.org/ratingsv01.html\" l r (n 0 s 0 v 0 l 0) gen true for \"http://www.yahoo.com\" r (n 0 s 0 v 0 l 0))'><style>a.h{background-color:#ffee99}</style></head>");
        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new TitleTag (),
                    new StyleTag (),
                    new MetaTag (),
                }));
        parseAndAssertNodeCount(7);
        assertTrue(node[2] instanceof TitleTag);
        // check the title node
        TitleTag titleTag = (TitleTag) node[2];
        assertEquals("Title","Yahoo!",titleTag.getTitle());
    }
View Full Code Here


        assertEquals ("Html node has five children", 5, html.getChildCount ());
        assertTrue ("Second child is a head tag", html.childAt (1) instanceof HeadTag);
        HeadTag head = (HeadTag)html.childAt (1);
        assertEquals ("Head node has two children", 2, head.getChildCount ());
        assertTrue ("Second child is a title tag", head.childAt (1) instanceof TitleTag);
        TitleTag titleTag = (TitleTag)head.childAt (1);
        assertEquals("Title","SISTEMA TERRA, VOL. VI , No. 1-3, December 1997",titleTag.getTitle());
// Note: this will fail because of the extra > inserted to finish the /TITLE tag:
//        assertStringEquals ("toHtml", text, html.toHtml ());
    }
View Full Code Here

        "<html><head><TITLE>\n"+
        "<html><head><TITLE>\n"+
        "Double tags can hang the code\n"+
        "</TITLE></head><body>\n"+
        "<body><html>");
        parser.setNodeFactory (new PrototypicalNodeFactory (new TitleTag ()));
        parseAndAssertNodeCount(9);
        assertTrue("Third tag should be a title tag",node[2] instanceof TitleTag);
        TitleTag titleTag = (TitleTag)node[2];
        assertEquals("Title","\n",titleTag.getTitle());
        assertTrue("Fourth tag should be a title tag",node[3] instanceof TitleTag);
        titleTag = (TitleTag)node[3];
        assertEquals("Title","\nDouble tags can hang the code\n",titleTag.getTitle());
    }
View Full Code Here

     */
    public void testNoEndTitleTag() throws ParserException {
        createParser(
        "<TITLE>KRP VALIDATION<PROCESS/TITLE>");
        parseAndAssertNodeCount(1);
        TitleTag titleTag = (TitleTag)node[0];
        assertEquals("Expected title","KRP VALIDATION",titleTag.getTitle());
    }
View Full Code Here

        createParser("<html><head>" + title + "<base href=http://www.yahoo.com/ target=_top><meta http-equiv=\"PICS-Label\" content='(PICS-1.1 \"http://www.icra.org/ratingsv02.html\" l r (cz 1 lz 1 nz 1 oz 1 vz 1) gen true for \"http://www.yahoo.com\" r (cz 1 lz 1 nz 1 oz 1 vz 1) \"http://www.rsac.org/ratingsv01.html\" l r (n 0 s 0 v 0 l 0) gen true for \"http://www.yahoo.com\" r (n 0 s 0 v 0 l 0))'><style>a.h{background-color:#ffee99}</style></head>");
        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new TitleTag (),
                    new BaseHrefTag (),
                    new MetaTag (),
                    new StyleTag (),
                }));
        parseAndAssertNodeCount(7);
        assertTrue(node[2] instanceof TitleTag);
        TitleTag titleTag = (TitleTag) node[2];
        assertStringEquals("HTML Rendering",title,titleTag.toHtml());
    }
View Full Code Here

        createParser("<html><head><TITLE>test page</TITLE><BASE HREF=\"http://www.abc.com/\"><a href=\"home.cfm\">Home</a>...</html>","http://www.google.com/test/index.html");
        parser.setNodeFactory (
            new PrototypicalNodeFactory (
                new Tag[]
                {
                    new TitleTag (),
                    new LinkTag (),
                    new BaseHrefTag (),
                }));
        parseAndAssertNodeCount(7);
        assertTrue("Base href tag should be the 4th tag", node[3] instanceof BaseHrefTag);
View Full Code Here

            "</html>"
        );
        parser.setNodeFactory (new PrototypicalNodeFactory (
            new Tag[] {
                new MetaTag (),
                new TitleTag (),
                new LinkTag (),
            }));
        parseAndAssertNodeCount(11);
        assertType("meta tag",MetaTag.class,node[3]);
        MetaTag metaTag = (MetaTag)node[3];
View Full Code Here

            "</html>");
        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

    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

    absorbLeadingBlanks(tagNameBeingChecked);
    return (tagNameBeingChecked.toUpperCase().startsWith(MATCH_NAME[0]) && null == previousOpenScanner);
  }

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

TOP

Related Classes of org.htmlparser.tags.TitleTag

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.