Package org.htmlparser.tags

Examples of org.htmlparser.tags.Tag


  public void testBrokenTag() throws ParserException {
    String testHTML1 = new String("<br");
    createParser(testHTML1);
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a tag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertEquals("Node contents", "br", tag.getText());
  }
View Full Code Here


  public void testTagInsideTag() throws ParserException {
    String testHTML = new String("<META name=\"Hello\" value=\"World </I>\">");
    createParser(testHTML);
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a tag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertEquals("Node contents", "META name=\"Hello\" value=\"World </I>\"", tag.getText());
    assertEquals("Meta Content", "World </I>", tag.getAttribute("value"));

  }
View Full Code Here

    String testHTML = new String(
        "<META NAME=\"Author\" CONTENT = \"DORIER-APPRILL E., GERVAIS-LAMBONY P., MORICONI-EBRARD F., NAVEZ-BOUCHANINE F.\"\">");
    createParser(testHTML);
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a tag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertStringEquals(
        "Node contents",
        "META NAME=\"Author\" CONTENT=\"DORIER-APPRILL E., GERVAIS-LAMBONY P., MORICONI-EBRARD F., NAVEZ-BOUCHANINE F.\"",
        tag.getText());
    Hashtable table = tag.getAttributes();
    assertEquals("Meta Content", "DORIER-APPRILL E., GERVAIS-LAMBONY P., MORICONI-EBRARD F., NAVEZ-BOUCHANINE F.",
        tag.getAttribute("CONTENT"));

  }
View Full Code Here

    String testHTML = new String(
        "<META NAME=\"Keywords\" CONTENT=Moscou, modernisation, politique urbaine, sp�cificit�s culturelles, municipalit�, Moscou, modernisation, urban politics, cultural specificities, municipality\">");
    createParser(testHTML);
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a tag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertStringEquals(
        "Node contents",
        "META NAME=\"Keywords\" CONTENT=\"Moscou, modernisation, politique urbaine, sp�cificit�s culturelles, municipalit�, Moscou, modernisation, urban politics, cultural specificities, municipality\"",
        tag.getText());
  }
View Full Code Here

    String testHTML = new String(
        "<meta name=\"description\" content=\"Une base de donn�es sur les th�ses de g\"ographie soutenues en France \">");
    createParser(testHTML);
    parseAndAssertNodeCount(1);
    assertTrue("Node should be a tag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertEquals(
        "Node contents",
        "meta name=\"description\" content=\"Une base de donn�es sur les th�ses de gographie soutenues en France\"",
        tag.getText());
  }
View Full Code Here

  public void testAttributesReconstruction() throws ParserException {
    String testHTML = "<TEXTAREA name=\"JohnDoe\" ></TEXTAREA>";
    createParser(testHTML);
    parseAndAssertNodeCount(2);
    assertTrue("First node should be an HTMLtag", node[0] instanceof Tag);
    Tag htmlTag = (Tag) node[0];
    String expectedHTML = "<TEXTAREA NAME=\"JohnDoe\">";
    assertStringEquals("Expected HTML", expectedHTML, htmlTag.toHtml());
  }
View Full Code Here

    String testHTML = "<A \n"
        + "HREF=\"/a?b=c>d&e=f&g=h&i=http://localhost/Testing/Report1.html\">20020702 Report 1</A>";
    createParser(testHTML);
    Node node = Tag.find(parser.getReader(), testHTML, 0);
    assertTrue("Node should be a tag", node instanceof Tag);
    Tag tag = (Tag) node;
    String href = tag.getAttribute("HREF");
    assertStringEquals("Resolved Link", "/a?b=c>d&e=f&g=h&i=http://localhost/Testing/Report1.html", href);

  }
View Full Code Here

  public void testParameterChange() throws ParserException {
    createParser("<TABLE BORDER=0>");
    parseAndAssertNodeCount(1);
    // the node should be an HTMLTag
    assertTrue("Node should be a HTMLTag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertEquals("Initial text should be", "TABLE BORDER=0", tag.getText());

    Hashtable tempHash = tag.getAttributes();
    tempHash.put("BORDER", "1");
    tag.setAttributes(tempHash);

    String s = tag.toHtml();
    assertEquals("HTML should be", "<TABLE BORDER=\"1\" >", s);
  }
View Full Code Here

  /**
   * This is the reproduction of a bug which causes a null pointer exception
   */
  public void testExtractLinkInvertedCommasBug() throws ParserException {
    String tagContents = "a href=r/anorth/top.html";
    Tag tag = new Tag(new TagData(0, 0, tagContents, ""));
    String url = "c:\\cvs\\html\\binaries\\yahoo.htm";
    LinkScanner scanner = new LinkScanner("-l");
    assertEquals("Extracted Link", "r/anorth/top.html", scanner.extractLink(tag, url));
  }
View Full Code Here

    assertEquals("String Contents", "Hello World", stringNode.getText());
  }

  public void testReplaceFaultyTagWithEndTag() throws ParserException {
    String currentLine = "<p>Site Comments?<br><a href=\"mailto:sam@neurogrid.com?subject=Site Comments\">Mail Us<a></p>";
    Tag tag = new Tag(new TagData(85, 87, "a", currentLine));
    LinkScanner linkScanner = new LinkScanner();
    String newLine = linkScanner.replaceFaultyTagWithEndTag(tag, currentLine);
    assertEquals("Expected replacement",
        "<p>Site Comments?<br><a href=\"mailto:sam@neurogrid.com?subject=Site Comments\">Mail Us</A></p>",
        newLine);
View Full Code Here

TOP

Related Classes of org.htmlparser.tags.Tag

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.