Package org.htmlparser.visitors

Examples of org.htmlparser.visitors.TagFindingVisitor


    assertEquals("UL tag found", 1, visitor.getTagCount(2));
    assertEquals("A tag found", 1, visitor.getTagCount(3));
  }

  public void testEndTags() throws Exception {
    TagFindingVisitor visitor = new TagFindingVisitor(new String[] { "LI", "BODY", "UL", "A" }, true);
    parser.visitAllNodesWith(visitor);
    assertEquals("LI tags found", 2, visitor.getTagCount(0));
    assertEquals("BODY tag found", 1, visitor.getTagCount(1));
    assertEquals("UL tag found", 1, visitor.getTagCount(2));
    assertEquals("A tag found", 1, visitor.getTagCount(3));
    assertEquals("BODY end tag found", 1, visitor.getEndTagCount(1));
  }
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] + " begin tags = " + tagFinder.getTagCount(i));
      System.out.println("Number of " + tagsBeingChecked[i] + " end tags = " + tagFinder.getEndTagCount(i));
    }

  }
View Full Code Here

    public void setUp() {
        createParser(html);
    }

    public void testTagFound() throws Exception {
        TagFindingVisitor visitor = new TagFindingVisitor(new String[] {"HEAD"});
        parser.visitAllNodesWith(visitor);
        assertEquals("HEAD found", 1, visitor.getTagCount(0));
    }
View Full Code Here

        parser.visitAllNodesWith(visitor);
        assertEquals("HEAD found", 1, visitor.getTagCount(0));
    }

    public void testTagsFound() throws Exception {
        TagFindingVisitor visitor = new TagFindingVisitor(new String [] {"LI"});
        parser.visitAllNodesWith(visitor);
        assertEquals("LI tags found", 2, visitor.getTagCount(0));
    }
View Full Code Here

        parser.visitAllNodesWith(visitor);
        assertEquals("LI tags found", 2, visitor.getTagCount(0));
    }

    public void testMultipleTags() throws Exception {
        TagFindingVisitor visitor =
            new TagFindingVisitor(
                new String [] {
                    "LI","BODY","UL","A"
                }
            );
        parser.visitAllNodesWith(visitor);
        assertEquals("LI tags found", 2, visitor.getTagCount(0));
        assertEquals("BODY tag found", 1, visitor.getTagCount(1));
        assertEquals("UL tag found", 1, visitor.getTagCount(2));
        assertEquals("A tag found", 1, visitor.getTagCount(3));
    }
View Full Code Here

        assertEquals("UL tag found", 1, visitor.getTagCount(2));
        assertEquals("A tag found", 1, visitor.getTagCount(3));
    }

    public void testEndTags() throws Exception {
        TagFindingVisitor visitor =
            new TagFindingVisitor(
                new String [] {
                    "LI","BODY","UL","A"
                },
                true
            );
        parser.visitAllNodesWith(visitor);
        assertEquals("LI tags found", 2, visitor.getTagCount(0));
        assertEquals("BODY tag found", 1, visitor.getTagCount(1));
        assertEquals("UL tag found", 1, visitor.getTagCount(2));
        assertEquals("A tag found", 1, visitor.getTagCount(3));
        assertEquals("BODY end tag found", 1, visitor.getEndTagCount(1));
    }
View Full Code Here

TOP

Related Classes of org.htmlparser.visitors.TagFindingVisitor

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.