Package org.htmlparser

Examples of org.htmlparser.StringNode


    createParser(testHTML);
    parser.registerScanners();
    Parser.setLineSeparator("\r\n"); // actually a static method
    parseAndAssertNodeCount(5);
    assertTrue("Third node should be a string node", node[2] instanceof StringNode);
    StringNode stringNode = (StringNode) node[2];
    String actual = stringNode.getText();
    assertEquals("Third node has incorrect text", "text<\r\n>text", actual);
  }
View Full Code Here


    createParser(testHTML);
    parser.registerScanners();
    Parser.setLineSeparator("\r\n"); // actually a static method
    parseAndAssertNodeCount(5);
    assertTrue("Third node should be a string node", node[2] instanceof StringNode);
    StringNode stringNode = (StringNode) node[2];
    String actual = stringNode.getText();
    assertEquals("Third node has incorrect text", "text<>\r\ntext", actual);
  }
View Full Code Here

    super.setUp();
    scriptScanner = new ScriptScanner();
  }

  public void testCreation() {
    StringNode stringNode = new StringNode(new StringBuffer("Script Code"), 0, 0);
    NodeList childVector = new NodeList();
    childVector.add(stringNode);
    ScriptTag scriptTag = new ScriptTag(new TagData(0, 10, "Tag Contents", "tagline"), new CompositeTagData(null,
        null, childVector));
View Full Code Here

    Node[] nodes = nodeList.toNodeArray();

    assertEquals("Number of nodes found", 1, nodes.length);
    assertType("search result node", StringNode.class, nodes[0]);
    StringNode stringNode = (StringNode) nodes[0];
    assertEquals("Expected contents of string node", "User Name", stringNode.getText());
  }
View Full Code Here

    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

    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);
    StringNode text = (StringNode) node;
    assertEquals("text", "Hello", text.toPlainTextString());
  }
View Full Code Here

    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);
    StringNode text = (StringNode) node;
    assertEquals("text", "Hello", text.toPlainTextString());
  }
View Full Code Here

    assertEquals("ending loc", 7, customTag.getStartTag().elementEnd());
    assertEquals("starting line position", 1, customTag.tagData.getStartLine());
    assertEquals("ending line position", 1, customTag.tagData.getEndLine());
    AnotherTag anotherTag = (AnotherTag) customTag.childAt(0);
    assertEquals("anotherTag child count", 1, anotherTag.getChildCount());
    StringNode stringNode = (StringNode) anotherTag.childAt(0);
    assertStringEquals("anotherTag child text", "something", stringNode.toPlainTextString());
    assertStringEquals("first custom tag html", "<CUSTOM><ANOTHER>something</ANOTHER></CUSTOM>", customTag.toHtml());
    customTag = (CustomTag) node[1];
    assertStringEquals("second custom tag html", "<CUSTOM><ANOTHER>else</ANOTHER></CUSTOM>", customTag.toHtml());
  }
View Full Code Here

      node = e.nextNode();

      if (node instanceof StringNode) {
        // Node is a plain string
        // Cast it to an HTMLStringNode
        StringNode stringNode = (StringNode) node;
        // Retrieve the data from the object
        buffer.append(stringNode.getText());
      } else if (node instanceof LinkTag) {
        // Node is a link
        // Cast it to an HTMLLinkTag
        LinkTag linkNode = (LinkTag) node;
        // Retrieve the data from the object and print it
View Full Code Here

          i = -1;
        }

      }
    }
    return new StringNode(textBuffer, textBegin, textEnd);
  }
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.