Java 类org.jsoup.nodes.Comment 实例源码

项目:jbossforge-html-parser    文件:HTMLElementImpl.java   
@Override
public List<HTMLNode> getChildren()
{
   if (children != null)
      return children;

   children = new ArrayList<HTMLNode>();

   for (Node node : target.childNodes())
   {
      HTMLNode htmlNode = null;
      if (node instanceof Comment)
      {
         htmlNode = new HTMLCommentImpl((Comment) node, this);
      }
      else if (node instanceof Element)
      {
         htmlNode = new HTMLElementImpl<Element>((Element) node, this);
      } else {
         htmlNode = new HTMLNodeImpl<Node>( node, this);
      }
      children.add(htmlNode);
   }

   return children;
}
项目:ascii_generate    文件:GetEmoticons.java   
private void print2(String baseLocation) throws IOException, TransformerException, ParserConfigurationException {
        Document document = Jsoup.connect(baseLocation).get();
        Elements content = document.getElementsByAttributeValue("class", "entry-content");
        String title = null;
        ArrayList<String> list = new ArrayList<>();
        for (Element div : content) {
            List<Node> nodes = div.childNodes();
            for (Node node : nodes) {
                if (node instanceof Element) {
                    if (((Element) node).tagName().equals("h3")) {
                        writeFile(title, list);
                        list.clear();
                        System.out.println("Title: " + node.childNode(0));
                        title = node.childNode(0).toString();
                    } else if (((Element) node).tagName().equals("table")) {
                        //print table
                        Elements tr = ((Element) node).getElementsByTag("tr");
                        for (Element element : tr) {
                            Elements td = element.getElementsByTag("td");
                            for (Element value : td) {
                                if (value.childNodeSize() > 0) {
                                    if (!(value.childNode(0) instanceof Comment)) {
//                                        System.out.println("Emoticon: " + value.childNode(0) + " " + value.childNode(0).getClass().getSimpleName());
                                        list.add(value.childNode(0).toString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
项目:common    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
          for (Node n : family) {
              if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false;
          }
        return true;
}
项目:gestock    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
        for (int i = 0; i < family.size(); i++) {
            Node n = family.get(i);
            if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false; 
        }
        return true;
}
项目:CN1ML-NetbeansModule    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
        for (int i = 0; i < family.size(); i++) {
            Node n = family.get(i);
            if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false; 
        }
        return true;
}
项目:astor    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
          for (Node n : family) {
              if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false;
          }
        return true;
}
项目:astor    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
          for (Node n : family) {
              if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false;
          }
        return true;
}
项目:astor    文件:HtmlParserTest.java   
@Test public void parsesComments() {
    String html = "<html><head></head><body><img src=foo><!-- <table><tr><td></table> --><p>Hello</p></body></html>";
    Document doc = Jsoup.parse(html);

    Element body = doc.body();
    Comment comment = (Comment) body.childNode(1); // comment should not be sub of img, as it's an empty tag
    assertEquals(" <table><tr><td></table> ", comment.getData());
    Element p = body.child(1);
    TextNode text = (TextNode) p.childNode(0);
    assertEquals("Hello", text.getWholeText());
}
项目:astor    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
          for (Node n : family) {
              if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false;
          }
        return true;
}
项目:astor    文件:HtmlParserTest.java   
@Test public void parsesComments() {
    String html = "<html><head></head><body><img src=foo><!-- <table><tr><td></table> --><p>Hello</p></body></html>";
    Document doc = Jsoup.parse(html);

    Element body = doc.body();
    Comment comment = (Comment) body.childNode(1); // comment should not be sub of img, as it's an empty tag
    assertEquals(" <table><tr><td></table> ", comment.getData());
    Element p = body.child(1);
    TextNode text = (TextNode) p.childNode(0);
    assertEquals("Hello", text.getWholeText());
}
项目:BoL-API-Parser    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
        for (int i = 0; i < family.size(); i++) {
            Node n = family.get(i);
            if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false; 
        }
        return true;
}
项目:AngelList-Mobile    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
        for (int i = 0; i < family.size(); i++) {
            Node n = family.get(i);
            if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false; 
        }
        return true;
}
项目:jsoup-learning    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
        for (int i = 0; i < family.size(); i++) {
            Node n = family.get(i);
            if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false; 
        }
        return true;
}
项目:opensearchserver    文件:JSoupHtmlNode.java   
@Override
public boolean isComment() {
    if (node instanceof Comment) {
        return true;
    }
    return false;
}
项目:idylfin    文件:Evaluator.java   
@Override
public boolean matches(Element root, Element element) {
        List<Node> family = element.childNodes();
        for (int i = 0; i < family.size(); i++) {
            Node n = family.get(i);
            if (!(n instanceof Comment || n instanceof XmlDeclaration || n instanceof DocumentType)) return false; 
        }
        return true;
}
项目:aet    文件:MarkupVisitor.java   
@Override
public void visit(Node node) {
  if (node instanceof TextNode || node instanceof Comment || node instanceof DataNode) {
    node.replaceWith(new TextNode(StringUtils.EMPTY, node.baseUri()));
  }
}
项目:astor    文件:HtmlTreeBuilder.java   
void insert(Token.Comment commentToken) {
    Comment comment = new Comment(commentToken.getData());
    insertNode(comment);
}
项目:astor    文件:HtmlTreeBuilder.java   
void insert(Token.Comment commentToken) {
    Comment comment = new Comment(commentToken.getData());
    insertNode(comment);
}
项目:jbossforge-html-parser    文件:HTMLCommentImpl.java   
HTMLCommentImpl(Comment target, HTMLElement parent)
{
   super(target, parent);
}