Package org.htmlparser

Examples of org.htmlparser.Parser.elements()


    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);
View Full Code Here


      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

    String url = "http://htmlparser.sourceforge.net/test/badtable2.html";

    parser = new Parser(url);
    if (1.4 <= Parser.getVersionNumber()) {
      parser.registerScanners();
      for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
        e.nextNode();
      // Note: The test will throw a StackOverFlowException,
      // so we are successful if we get to here...
      assertTrue("Crash", true);
    }
View Full Code Here

    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 {
      nextExpectedNode = getNextNodeUsing(expectedIterator);
View Full Code Here

    }
    parser.getReader().mark(5000);

    Node[] node = new Node[500];
    int i = 0;
    for (NodeIterator e = parser.elements(); e.hasMoreNodes();) {
      node[i++] = e.nextNode();
    }
    int cnt = i;
    parser.getReader().reset();
    // Now try getting the elements again
View Full Code Here

    }
    int cnt = i;
    parser.getReader().reset();
    // Now try getting the elements again
    i = 0;
    for (NodeIterator e = parser.elements(); e.hasMoreNodes();) {
      node[i++] = e.nextNode();
    }
    assertEquals("There should be " + cnt + " nodes identified (second call to parser.elements())", cnt, i);
  }
View Full Code Here

    } catch (Exception e) {
      throw new ParserException("You must be offline! This test needs you to be connected to the internet.", e);
    }

    pass = false;
    for (enumeration = parser.elements(); enumeration.hasMoreNodes();) {
      node = enumeration.nextNode();
      if (node instanceof StringNode) {
        string = (StringNode) node;
        if (-1 != string.getText().indexOf(postal_code))
          pass = true;
View Full Code Here

      out.println("</html>");
      out.close();
      parser = new Parser(file.getAbsolutePath());
      nodes = new Node[30];
      i = 0;
      for (enumeration = parser.elements(); enumeration.hasMoreNodes();) {
        nodes[i] = enumeration.nextNode();
        i++;
      }
      assertEquals("Expected nodes", 12, i);
    } catch (Exception e) {
View Full Code Here

    NodeIterator enumeration;

    try {
      parser = new Parser("http://www.sony.co.jp", Parser.noFeedback);
      assertEquals("Character set by default is ISO-8859-1", "ISO-8859-1", parser.getEncoding());
      enumeration = parser.elements();
      assertTrue("Character set should be Shift_JIS", parser.getEncoding().equalsIgnoreCase("Shift_JIS"));
    } catch (ParserException e) {
      fail("could not open http://www.sony.co.jp");
    }
  }
View Full Code Here

    Node[] nodes;

    parser = new Parser(url);
    i = 0;
    nodes = new Node[30];
    for (NodeIterator e = parser.elements(); e.hasMoreNodes();)
      nodes[i++] = e.nextNode();
    assertEquals("Expected nodes", 14, i);
  }

  /**
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.