Package org.htmlparser

Examples of org.htmlparser.Node.toHtml()


    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());
  }

  public void testCompositeTagWithAnotherTagChild() throws ParserException {
    createParser("<Custom>" + "<Another/>" + "</Custom>");
    parser.addScanner(new AnotherScanner());
View Full Code Here


    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());
  }

  public void testParseTwoCompositeTags() throws ParserException {
    createParser("<Custom>" + "</Custom>" + "<Custom/>");
    parser.addScanner(new CustomScanner());
View Full Code Here

        if (prevNode.elementEnd() > node.elementBegin()) {
          // Its a new line
          sb.append(lineSeparator);
        }
      }
      sb.append(node.toHtml());
      prevNode = node;
    }
    if (prevNode.elementEnd() > endTag.elementBegin()) {
      sb.append(lineSeparator);
    }
View Full Code Here

  public String getChildrenHTML() {
    StringBuffer buff = new StringBuffer();
    for (SimpleNodeIterator e = children(); e.hasMoreNodes();) {
      Node node = (Node) e.nextNode();
      buff.append(node.toHtml());
    }
    return buff.toString();
  }

  public void accept(NodeVisitor visitor) {
View Full Code Here

    }

    StringBuilder html = new StringBuilder(512);
    for (int i = index; i < nodes.size() && nodes.get(i) != endTag; i++) {
      Node node = nodes.get(i);
      html.append(node.toHtml());
    }

    return html.toString();
  }
View Full Code Here

        try {
            while ((cursor = lexer.nextNode()) != null) {
                if (cursor instanceof Remark) {
                    items.add(new SimpleComment(cursor.getText()));
                } else if (cursor instanceof Text) {
                    items.add(new SimpleText(cursor.toHtml()));
                } else if (cursor instanceof org.htmlparser.Tag) {
                    processTag(nodes, current, items, (org.htmlparser.Tag) cursor);
                } else {
                    throw new BrixException("Unknown node type " + cursor.getClass().getName());
                }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.