Package org.htmlparser

Examples of org.htmlparser.Node


     * Check if more nodes are available.
     * @return <code>true</code> if a call to <code>nextHTMLNode()</code> will succeed.
     */
    public boolean hasMoreNodes() throws ParserException
    {
        Node node;
        boolean ret;

        if (null == reader)
            ret = false;
        else if (0 != preRead.size())
View Full Code Here


     * Get the next node.
     * @return The next node in the HTML stream, or null if there are no more nodes.
     */
    public Node nextNode() throws ParserException
    {
        Node ret;

        if (hasMoreNodes())
            ret = (Node) preRead.remove(0);
        else
            // should perhaps throw an exception?
View Full Code Here

    }

    public void testAttributes()
    {
        NodeIterator iterator;
        Node node;
        Hashtable attributes;

        try
        {
            createParser("<body style=\"margin-top:4px; margin-left:20px;\" title=\"body\">");
View Full Code Here

    assertEquals("starting loc",0,customTag.getStartTag().elementBegin());
    assertEquals("ending loc",7,customTag.getStartTag().elementEnd());
    assertEquals("starting line position",1,customTag.tagData.getStartLine());
    assertEquals("ending line position",1,customTag.tagData.getEndLine());
   
    Node child = customTag.childAt(0);
    assertType("child",StringNode.class,child);
    StringNode text = (StringNode)child;
    assertStringEquals("child text","Hello",child.toPlainTextString());
  }
View Full Code Here

    assertEquals("starting loc",0,customTag.getStartTag().elementBegin());
    assertEquals("ending loc",7,customTag.getStartTag().elementEnd());
    assertEquals("custom tag starting loc",0,customTag.elementBegin());
    assertEquals("custom tag ending loc",23,customTag.elementEnd());

    Node child = customTag.childAt(0);
    assertType("child",Tag.class,child);
    Tag tag = (Tag)child;
    assertStringEquals("child html","<HELLO>",child.toHtml());
  }
View Full Code Here

    assertEquals("starting loc",0,customTag.getStartTag().elementBegin());
    assertEquals("ending loc",7,customTag.getStartTag().elementEnd());
    assertEquals("custom tag starting loc",0,customTag.elementBegin());
    assertEquals("custom tag ending loc",26,customTag.elementEnd());

    Node child = customTag.childAt(0);
    assertType("child",AnotherTag.class,child);
    AnotherTag tag = (AnotherTag)child;
    assertEquals("another tag start pos",8,tag.elementBegin());
    assertEquals("another tag ending pos",17,tag.elementEnd());
   
    assertEquals("custom end tag start pos",18,customTag.getEndTag().elementBegin());
    assertStringEquals("child html","<ANOTHER/>",child.toHtml());
  }
View Full Code Here

    parser.addScanner(new AnotherScanner());
    parseAndAssertNodeCount(2);
    assertType("first node",CustomTag.class,node[0]);
    assertType("second node",CustomTag.class,node[1]);
    CustomTag customTag = (CustomTag)node[0];
    Node node = customTag.childAt(0);
    assertType("first child",AnotherTag.class,node);
    node = customTag.childAt(1);
    assertType("second child",CustomTag.class,node);
 
View Full Code Here

    parser.addScanner(new AnotherScanner());
    parseAndAssertNodeCount(2);
    assertType("first node",CustomTag.class,node[0]);
    assertType("second node",CustomTag.class,node[1]);
    CustomTag customTag = (CustomTag)node[0];
    Node node = customTag.childAt(0);
    assertType("first child",AnotherTag.class,node);
    AnotherTag anotherTag = (AnotherTag)node;
    assertEquals("another tag children count",1,anotherTag.getChildCount());
    node = anotherTag.childAt(0);
    assertType("nested child",StringNode.class,node);
View Full Code Here

    parseAndAssertNodeCount(2);
    assertType("first node",CustomTag.class,node[0]);
    assertType("second node",CustomTag.class,node[1]);
    CustomTag customTag = (CustomTag)node[0];
    assertEquals("first custom tag children count",5,customTag.getChildCount());
    Node node = customTag.childAt(0);
    assertType("first child",AnotherTag.class,node);
    AnotherTag anotherTag = (AnotherTag)node;
    assertEquals("another tag children count",1,anotherTag.getChildCount());
    node = anotherTag.childAt(0);
    assertType("nested child",StringNode.class,node);
View Full Code Here

    assertNull(
      "second custom tag should have no parent",
      customTag.getParent()
    );
 
    Node firstChild = customTag.childAt(0);
    assertType("firstChild",StringNode.class,firstChild);
    CompositeTag parent = firstChild.getParent();
    assertNotNull("first child parent should not be null",parent);
    assertSame("parent and custom tag should be the same",customTag,parent);
   
    EndTag endTag = (EndTag)node[2];
    assertStringEquals(
View Full Code Here

TOP

Related Classes of org.htmlparser.Node

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.