Package org.htmlparser

Examples of org.htmlparser.Parser


        throws Exception
    {
        expected = removeEscapeCharacters(expected);
        actual = removeEscapeCharacters(actual);

        Parser expectedParser = Parser.createParser(expected);
        Parser resultParser = Parser.createParser(actual);

        NodeIterator expectedIterator = expectedParser.elements();
        NodeIterator actualIterator = resultParser.elements();
        displayMessage =
            createGenericFailureMessage(displayMessage, expected, actual);

        Node nextExpectedNode = null, nextActualNode = null;
        do
View Full Code Here


    }

    public void testZeroArgConstructor()
        throws IOException, ClassNotFoundException, ParserException
    {
        Parser parser;
        byte[] data;

        parser = new Parser();
        data = pickle(parser);
        parser = (Parser) unpickle(data);
    }
View Full Code Here

    }

    public void testSerializable()
        throws IOException, ClassNotFoundException, ParserException
    {
        Parser parser;
        Vector vector;
        NodeIterator enumeration;
        byte[] data;

        parser =
            new Parser("http://htmlparser.sourceforge.net/test/example.html");
        enumeration = parser.elements();
        vector = new Vector(50);
        while (enumeration.hasMoreNodes())
            vector.addElement(enumeration.nextNode());

        data = pickle(parser);
        parser = (Parser) unpickle(data);

        enumeration = parser.elements();
        while (enumeration.hasMoreNodes())
            assertEquals(
                "Nodes before and after serialization differ",
                ((Node) vector.remove(0)).toHtml(),
                ((Node) enumeration.nextNode()).toHtml());
View Full Code Here

    }

    public void testSerializableScanners()
        throws IOException, ClassNotFoundException, ParserException
    {
        Parser parser;
        Vector vector;
        NodeIterator enumeration;
        byte[] data;

        parser =
            new Parser("http://htmlparser.sourceforge.net/test/example.html");
        parser.registerScanners();
        enumeration = parser.elements();
        vector = new Vector(50);
        while (enumeration.hasMoreNodes())
            vector.addElement(enumeration.nextNode());

        data = pickle(parser);
        parser = (Parser) unpickle(data);

        enumeration = parser.elements();
        while (enumeration.hasMoreNodes())
            assertEquals(
                "Nodes before and after serialization differ",
                ((Node) vector.remove(0)).toHtml(),
                ((Node) enumeration.nextNode()).toHtml());
View Full Code Here

     * See also feature request #725376 Handle script in attributes.
     * Only perform this test if it's version 1.4 or higher.
     */
    public void testJspWithinAttributes()
    {
        Parser parser;

        parser = new Parser();
        if (1.4 <= Parser.getVersionNumber())
        {
            getParameterTableFor("a href=\"<%=Application(\"sURL\")%>/literature/index.htm");
            assertStringEquals(
                "href",
View Full Code Here

     * See feature request #725376 Handle script in attributes.
     * Only perform this test if it's version 1.4 or higher.
     */
    public void testScriptedTag()
    {
        Parser parser;

        parser = new Parser();
        if (1.4 <= Parser.getVersionNumber())
        {
            getParameterTableFor("body onLoad=defaultStatus=''");
            String name = (String) table.get(Tag.TAGNAME);
            assertNotNull("No Tag.TAGNAME", name);
View Full Code Here

    this.file = file;
    this.numTimes = numTimes;   
  }

  public void beginTestWithoutScanners() throws ParserException {
    Parser parser;
    long sumTimes=0;
    double avg=0;
    System.out.println("***************************************");
    System.out.println("*  Test Without Scanners Registered   *");
    System.out.println("***************************************");       
    for (int i=0;i<=numTimes;i++) {
      // Create the parser object
      parser = new Parser(file,new DefaultParserFeedback());
      Node node;
      long start=System.currentTimeMillis();
      for (NodeIterator e = parser.elements();e.hasMoreNodes();) {
        node = e.nextNode();
      }
      long elapsedTime=System.currentTimeMillis()-start;
      if (i!=0)
      sumTimes += elapsedTime;
View Full Code Here

    System.out.println("Average Time : "+avg+" ms");
    System.out.println("***************************************");
  }

  public void beginTestWithScanners() throws ParserException {
    Parser parser;
    long sumTimes=0;
    double avg=0;
    System.out.println("***************************************");
    System.out.println("*    Test With Scanners Registered    *");
    System.out.println("***************************************");         
    for (int i=0;i<=numTimes;i++) {
      // Create the parser object
      parser = new Parser(file,new DefaultParserFeedback());
      parser.registerScanners();
      Node node;
      long start=System.currentTimeMillis();
      for (NodeIterator e = parser.elements();e.hasMoreNodes();) {
        node = e.nextNode();
      }
      long elapsedTime=System.currentTimeMillis()-start;
      if (i!=0)
      sumTimes += elapsedTime;
View Full Code Here

        return imgTagCount;
    }

    public int countImageTagsWithHTMLParser() throws ParserException
    {
        Parser parser =
            new Parser("http://www.yahoo.com", new DefaultParserFeedback());
        parser.addScanner(new ImageScanner("-i", new LinkProcessor()));
        int parserImgTagCount = 0;
        Node node;
        for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
        {
            node = (Node) e.nextNode();
            if (node instanceof ImageTag)
            {
                parserImgTagCount++;
View Full Code Here

    private void identify(String string) throws Exception
    {
        String[] tagsBeingChecked = { "TABLE", "DIV", "SPAN" };

        Parser parser = new Parser("http://www.amazon.com");
        TagFindingVisitor tagFinder =
            new TagFindingVisitor(tagsBeingChecked, true);
        parser.visitAllNodesWith(tagFinder);
        for (int i = 0; i < tagsBeingChecked.length; i++)
        {
            System.out.println(
                "Number of "
                    + tagsBeingChecked[i]
View Full Code Here

TOP

Related Classes of org.htmlparser.Parser

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.