Package org.htmlparser.visitors

Examples of org.htmlparser.visitors.NodeVisitor


    if (DebugFile.trace) {
      DebugFile.writeln("Begin HtmlMimeBodyPart.addClickThroughRedirector("+sRedirectorUrl+")");
      DebugFile.incIdent();
    }
   
    final NodeVisitor linkVisitor = new NodeVisitor() {

        public void visitTag(Tag tag) {
            // Process any tag/node in your HTML
            String name = tag.getTagName();
            // Set the Link's target to _blank if the href is external
View Full Code Here


      throw new NullPointerException("Input HTML code string is NULL");
    }   
    try{
      Parser parser = Parser.createParser(htmlCode, "UTF-8");
      final NodeList nl = parser.parse(null);
      nl.visitAllNodesWith(new NodeVisitor(){
        @SuppressWarnings("unchecked")
        public void visitTag(Tag tag){
          if((tag instanceof ScriptTag) ||
             (tag instanceof FrameTag)){
            if(tag.getParent() == null){
View Full Code Here

  @Override
  public void visitTextFragment(final VisitorContext ctx, TextFragment text) {
    final List<MessageFragment> result = new ArrayList<MessageFragment>();
    Parser parser = Parser.createParser(text.getText(), "UTF-8");
    try {
      parser.visitAllNodesWith(new NodeVisitor() {
        @Override
        public void visitEndTag(Tag tag) {
          result.add(ctx.createNonlocalizableTextFragment(tag.toHtml(true)));
        }
View Full Code Here

                                                           ParserException {
        logger.debug("Processing an HTML document");

        String stream = null;
        Parser parser = null;
        NodeVisitor visitor = null;

        // Retrieve HTML stream
        stream =
                readFully(new InputStreamReader(method.getResponseBodyAsStream()));
View Full Code Here

    final List<UrlData> dataList = new ArrayList<UrlData>();
    try {
      Parser parser = new Parser();
      parser.setURL(channelUrl);
      parser.setEncoding("Gb2312");
      NodeVisitor visitor = new NodeVisitor() {

        public void visitTag(Tag tag) {
          if (Div.class.equals(tag.getClass())
              && "m".equals(tag.getAttribute("class"))
              && "sortlist".equals(tag.getAttribute("id"))) {
            tag.accept(new NodeVisitor() {
              public void visitTag(Tag tag) {
                if (Div.class.equals(tag.getClass())
                    && "con".equals(tag
                        .getAttribute("class"))) {
                  tag.accept(new NodeVisitor() {
                    public void visitTag(Tag tag) {
                      UrlData data = new UrlData();
                      if (LinkTag.class.equals(tag
                          .getClass())) {
                        data.setUrlName(tag
View Full Code Here

    final List<Data> dataList = new ArrayList<Data>();
    try {
      Parser parser = new Parser();
      parser.setURL(url);
      parser.setEncoding("Gb2312");
      NodeVisitor visitor = new NodeVisitor() {

        public void visitTag(Tag tag) {
          if (Div.class.equals(tag.getClass())
              && "p-img".equals(tag.getAttribute("class"))) {
            final Data data = new Data();
            tag.accept(new NodeVisitor() {
              public void visitTag(Tag tag) {
                if (ImageTag.class.equals(tag.getClass())) {
                  data.setName(tag.getAttribute("alt"));
                }
                if (LinkTag.class.equals(tag.getClass())) {
View Full Code Here

    }
  }

  private static String javaHtmlParser( String content ) throws ParserException {

    final NodeVisitor linkVisitor = new NodeVisitor() {

      @Override
      public void visitTag( Tag tag ) {

        String name = tag.getTagName();
View Full Code Here

            Exception
    {
        Parser parser = Parser.createParser (HTML_WITH_LINK, null);
        NodeList list = parser.parse (null); // no filter
        // make an inner class that does the same thing as the UrlModifyingVisitor
        NodeVisitor visitor = new NodeVisitor ()
        {
            String linkPrefix = "localhost://";
            public void visitTag (Tag tag)
            {
                if (tag instanceof LinkTag)
View Full Code Here

TOP

Related Classes of org.htmlparser.visitors.NodeVisitor

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.