Package org.htmlparser.lexer

Examples of org.htmlparser.lexer.Lexer.nextNode()


            String lineNumbers = "1";
            String template = null;
            tags.push(new HtmlSnippet(lineNumbers, filePath));

            // NOTE done like this the tags can be cached for faster processing
            while ((node = lexer.nextNode()) != null) {
                if (node instanceof Remark) {
                    // TODO need to pick up on comments within tags; at the
                    // moment this splits a tag into two causing a
                    // failure later
                    continue;
View Full Code Here


        Node node = null;

        while (true) {
            try {
                node = lexer.nextNode();
                if (node == null) {
                    break;
                }

                if (node instanceof Tag) {
View Full Code Here

                    Tag tag = (Tag) node;
                    String tagReadonly = tag.getAttribute("readonly");
                    String tagName = tag.getRawTagName();

                    if (tagName.equals("textarea") && tagReadonly != null && tagReadonly.equals("readonly")) {
                        node = lexer.nextNode();
                        if (node instanceof Text) {
                            String text = ((Text) node).getText();
                            text = Translate.decode(text);
                            this.texts.put(text);
                        }
View Full Code Here

            String lineNumbers = "1";
            String template = null;
            tags.push(new HtmlSnippet(lineNumbers, filePath));

            // NOTE done like this the tags can be cached for faster processing
            while ((node = lexer.nextNode()) != null) {
                if (node instanceof Remark) {
                    // TODO need to pick up on comments within tags; at the
                    // moment this splits a tag into two causing a
                    // failure later
                    continue;
View Full Code Here

            String lineNumbers = "1";
            String template = null;
            tags.push(new HtmlSnippet(lineNumbers, filePath));

            // NOTE done like this the tags can be cached for faster processing
            while ((node = lexer.nextNode()) != null) {
                if (node instanceof Remark) {
                    // TODO need to pick up on comments within tags; at the moment this splits a tag into two causing a
                    // failure later
                    continue;
View Full Code Here

  public static String html2Text(String html, int len) {
    try {
      Lexer lexer = new Lexer(html);
      Node node;
      StringBuilder sb = new StringBuilder(html.length());
      while ((node = lexer.nextNode()) != null) {
        if (node instanceof TextNode) {
          sb.append(node.toHtml());
        }
        if (sb.length() > len) {
          break;
View Full Code Here

    }
    try {
      Lexer lexer = new Lexer(txt);
      Node node;
      StringBuilder sb = new StringBuilder((int) (txt.length() * 1.2));
      while ((node = lexer.nextNode()) != null) {
        if (node instanceof TextNode) {
          sb.append(StringUtils.replaceEach(node.toHtml(), searchArr,
              replacementArr));
        } else {
          sb.append(node.toHtml());
View Full Code Here

        TagNode output;
       
        lexer = new Lexer (text);
        try
        {
            output = (TagNode)lexer.nextNode ();
            mPage = output.getPage ();
            nodeBegin = output.getStartPosition ();
            nodeEnd = output.getEndPosition ();
            mAttributes = output.getAttributesEx ();
        }
View Full Code Here

        Lexer lexer;
        Text node;

        reference = "Hello world";
        lexer = new Lexer (reference);
        node = (Text)lexer.nextNode ();
        assertEquals ("Text contents wrong", reference, node.getText ());
    }

    /**
     * Test operation with Unix line endings.
View Full Code Here

        Lexer lexer;
        Text node;

        reference = "Hello\nworld";
        lexer = new Lexer (reference);
        node = (Text)lexer.nextNode ();
        assertEquals ("Text contents wrong", reference, node.getText ());
    }

    /**
     * Test operation with Dos line endings.
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.