Package org.htmlparser.util

Examples of org.htmlparser.util.NodeList.toHtml()


    if (DebugFile.trace) {
      DebugFile.decIdent();
      DebugFile.writeln("End HtmlMimeBodyPart.addClickThroughRedirector()");
    }

    return list.toHtml();
  } // addClickThroughRedirector

}
View Full Code Here


          for(String a2r : attrs2remove){
            tag.removeAttribute(a2r);
          }
        }
      });     
      return nl.toHtml();
    }catch(Exception e){
      System.out.println(e);
    }
    return "";
  }
View Full Code Here

      Parser htmlParser = new Parser();
      htmlParser.setNodeFactory(factory);
      Parser.createParser(content,"UTF-8");
      htmlParser.setInputHTML(content);
      NodeList nodeList = htmlParser.parse(null);
      content = nodeList.toHtml();
    }catch(Exception e){
      logger.error(e);
    }
    return content;
  }
View Full Code Here

            NodeList heads = parser.parse(new TagNameFilter("HEAD"));
            if (heads.size() != 1)
                throw new DiscoveryException(
                        "HTML response must have exactly one HEAD element, " +
                                "found " + heads.size() + " : " + heads.toHtml());
            Node head = heads.elementAt(0);
            for (NodeIterator i = head.getChildren().elements();
                 i.hasMoreNodes();)
            {
                Node node = i.nextNode();
View Full Code Here

            NodeList heads = parser.parse(new TagNameFilter("HEAD"));
            if (heads.size() != 1)
                throw new DiscoveryException(
                        "HTML response must have exactly one HEAD element, " +
                                "found " + heads.size() + " : " + heads.toHtml());
            Node head = heads.elementAt(0);
            for (NodeIterator i = head.getChildren().elements();
                 i.hasMoreNodes();)
            {
                Node node = i.nextNode();
View Full Code Here

            if (heads.size() != 1)
                throw new YadisException(
                        "HTML response must have exactly one HEAD element, " +
                                "found " + heads.size() + " : "
                                + heads.toHtml(),
                        YadisResult.HTMLMETA_INVALID_RESPONSE);

            Node head = heads.elementAt(0);
            for (NodeIterator i = head.getChildren().elements();
                 i.hasMoreNodes();)
View Full Code Here

        BaseHrefTag baseTag = new BaseHrefTag();
        baseTag.setBaseUrl(base);
        nl.add(baseTag);

        // re-initializing the parser with the fixed content
        parser.setInputHTML(nl.toHtml());

        // listing all LinkTag nodes
        list = parser.extractAllNodesThatMatch(filter);
      }
      catch (ParserException e)
View Full Code Here

        BaseHrefTag baseTag = new BaseHrefTag();
        baseTag.setBaseUrl(base);
        nl.add(baseTag);

        // re-initializing the parser with the correct content
        parser.setInputHTML(nl.toHtml());

        // listing all LinkTag nodes
        list = parser.extractAllNodesThatMatch(filter);
      } catch (ParserException e) {
        reporter.incrCounter(LinkCounter.PARSER_FAILED, 1);
View Full Code Here

    Parser parser = new Parser(new Lexer(new Page(html)));
    NodeList tree = parser.parse(null);

    NodeList cloneTree = deepClone(tree);

    assertEquals(html, cloneTree.toHtml());
    assertEquals(tree.toString(), cloneTree.toString());
    assertFalse(tree.elementAt(0).getChildren().elementAt(1) == cloneTree.elementAt(0).getChildren().elementAt(1));
    assertFalse(tree.elementAt(0).getChildren().elementAt(1).getParent() == cloneTree.elementAt(0).getChildren().elementAt(1).getParent());
  }
View Full Code Here

    assertSame(Div.class, cloneTree.elementAt(0).getClass());

    ((Div) cloneTree.elementAt(0)).setAttribute("id", "blah-div");

    assertFalse(tree.toHtml().equals(cloneTree.toHtml()));
  }

  @Test
  public void flatCloneShouldJustGiveACopyOfANode() throws ParserException {
    String html = "<div class='foo'>funky <em>content</em></div>";
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.