Package org.htmlparser

Examples of org.htmlparser.StringNode


        createParser("<HTML><HEAD><TITLE>This is the Title</TITLE></HEAD><BODY>Hello World, this is the HTML Parser</BODY></HTML>");
        parseAndAssertNodeCount(10);
        assertTrue(
            "Fourth Node identified must be a string node",
            node[3] instanceof StringNode);
        StringNode stringNode = (StringNode) node[3];
        assertEquals(
            "First String Node",
            "This is the Title",
            stringNode.toPlainTextString());
        assertTrue(
            "Eighth Node identified must be a string node",
            node[7] instanceof StringNode);
        stringNode = (StringNode) node[7];
        assertEquals(
            "Second string node",
            "Hello World, this is the HTML Parser",
            stringNode.toPlainTextString());
    }
View Full Code Here


        createParser("<HTML><HEAD><TITLE>This is the Title</TITLE></HEAD><BODY>Hello World, this is the HTML Parser</BODY></HTML>");
        parseAndAssertNodeCount(10);
        assertTrue(
            "Fourth Node identified must be a string node",
            node[3] instanceof StringNode);
        StringNode stringNode = (StringNode) node[3];
        assertEquals(
            "First String Node",
            "This is the Title",
            stringNode.toHtml());
        assertTrue(
            "Eighth Node identified must be a string node",
            node[7] instanceof StringNode);
        stringNode = (StringNode) node[7];
        assertEquals(
            "Second string node",
            "Hello World, this is the HTML Parser",
            stringNode.toHtml());
    }
View Full Code Here

            "Second node should be HTMLRemarkNode",
            node[1] instanceof RemarkNode);
        assertTrue(
            "Third node should be HTMLStringNode",
            node[2] instanceof StringNode);
        StringNode stringNode = (StringNode) node[0];
        assertEquals(
            "First String node contents",
            "Before Comment ",
            stringNode.getText());
        StringNode stringNode2 = (StringNode) node[2];
        assertEquals(
            "Second String node contents",
            " After Comment",
            stringNode2.getText());
        RemarkNode remarkNode = (RemarkNode) node[1];
        assertEquals("Remark Node contents", " Comment ", remarkNode.getText());

    }
View Full Code Here

        createParser("a");
        parseAndAssertNodeCount(1);
        assertTrue(
            "First node should be HTMLStringNode",
            node[0] instanceof StringNode);
        StringNode stringNode = (StringNode) node[0];
        assertEquals("First String node contents", "a", stringNode.getText());
    }
View Full Code Here

        createParser("a\n\nb");
        parseAndAssertNodeCount(1);
        assertTrue(
            "First node should be HTMLStringNode",
            node[0] instanceof StringNode);
        StringNode stringNode = (StringNode) node[0];
        assertStringEquals(
            "First String node contents",
            "a\r\n\r\nb",
            stringNode.getText());
    }
View Full Code Here

    public void testStringWithLineBreaks() throws Exception
    {
        createParser("Testing &\nRefactoring");
        parseAndAssertNodeCount(1);
        assertType("first node", StringNode.class, node[0]);
        StringNode stringNode = (StringNode) node[0];
        assertStringEquals(
            "text",
            "Testing &\r\nRefactoring",
            stringNode.toPlainTextString());
    }
View Full Code Here

    parseAndAssertNodeCount(6);
    // The first node should be a Tag
    assertTrue("First node should be a Tag", node[0] instanceof Tag);
    // The second node should be a HTMLStringNode
    assertTrue("Second node should be a HTMLStringNode", node[1] instanceof StringNode);
    StringNode stringNode = (StringNode) node[1];
    assertEquals("Text of the StringNode", "Site Comments?", stringNode.getText());
    assertTrue("Third node should be a tag", node[2] instanceof Tag);

  }
View Full Code Here

    // assertEquals("Length of link tag",exp.length(),
    // linkTag.getLink().length());
    assertStringEquals("Link URL of link tag", exp, linkTag.getLink());
    assertEquals("Link Text of link tag", " Journalism 3.0", linkTag.getLinkText());
    assertTrue("Eight node should be a string node", node[7] instanceof StringNode);
    StringNode stringNode = (StringNode) node[7];
    assertEquals("String node contents", " by Rajesh Jain", stringNode.getText());
  }
View Full Code Here

    assertTrue("Second data node shouls be a String Node", dataNode[1] instanceof StringNode);

    // Check the contents of each data node
    ImageTag imageTag = (ImageTag) dataNode[0];
    assertEquals("Image URL", "http://www.yahoo.com/abcd.jpg", imageTag.getImageURL());
    StringNode stringNode = (StringNode) dataNode[1];
    assertEquals("String Contents", "Hello World", stringNode.getText());
  }
View Full Code Here

    parseAndAssertNodeCount(3);
    assertTrue("Node 0 should be a tag", node[0] instanceof Tag);
    Tag tag = (Tag) node[0];
    assertEquals("Tag Contents", "a", tag.getText());
    assertTrue("Node 1 should be a string node", node[1] instanceof StringNode);
    StringNode stringNode = (StringNode) node[1];
    assertEquals("StringNode Contents", "Revision", stringNode.getText());
    assertTrue("Node 2 should be a string node", node[2] instanceof EndTag);
    EndTag endTag = (EndTag) node[2];
    assertEquals("End Tag Contents", "a", endTag.getText());
  }
View Full Code Here

TOP

Related Classes of org.htmlparser.StringNode

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.