当前位置: 首页>>代码示例>>Java>>正文


Java Comment类代码示例

本文整理汇总了Java中org.jsoup.nodes.Comment的典型用法代码示例。如果您正苦于以下问题:Java Comment类的具体用法?Java Comment怎么用?Java Comment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Comment类属于org.jsoup.nodes包,在下文中一共展示了Comment类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getChildren

import org.jsoup.nodes.Comment; //导入依赖的package包/类
@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;
}
 
开发者ID:jerr,项目名称:jbossforge-html-parser,代码行数:27,代码来源:HTMLElementImpl.java

示例2: print2

import org.jsoup.nodes.Comment; //导入依赖的package包/类
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());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
 
开发者ID:tranleduy2000,项目名称:ascii_generate,代码行数:34,代码来源:GetEmoticons.java

示例3: matches

import org.jsoup.nodes.Comment; //导入依赖的package包/类
@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;
}
 
开发者ID:cpusoft,项目名称:common,代码行数:9,代码来源:Evaluator.java

示例4: matches

import org.jsoup.nodes.Comment; //导入依赖的package包/类
@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;
}
 
开发者ID:rogerxaic,项目名称:gestock,代码行数:10,代码来源:Evaluator.java

示例5: parsesComments

import org.jsoup.nodes.Comment; //导入依赖的package包/类
@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());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:12,代码来源:HtmlParserTest.java

示例6: isComment

import org.jsoup.nodes.Comment; //导入依赖的package包/类
@Override
public boolean isComment() {
	if (node instanceof Comment) {
		return true;
	}
	return false;
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:8,代码来源:JSoupHtmlNode.java

示例7: visit

import org.jsoup.nodes.Comment; //导入依赖的package包/类
@Override
public void visit(Node node) {
  if (node instanceof TextNode || node instanceof Comment || node instanceof DataNode) {
    node.replaceWith(new TextNode(StringUtils.EMPTY, node.baseUri()));
  }
}
 
开发者ID:Cognifide,项目名称:aet,代码行数:7,代码来源:MarkupVisitor.java

示例8: insert

import org.jsoup.nodes.Comment; //导入依赖的package包/类
void insert(Token.Comment commentToken) {
    Comment comment = new Comment(commentToken.getData());
    insertNode(comment);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:5,代码来源:HtmlTreeBuilder.java

示例9: HTMLCommentImpl

import org.jsoup.nodes.Comment; //导入依赖的package包/类
HTMLCommentImpl(Comment target, HTMLElement parent)
{
   super(target, parent);
}
 
开发者ID:jerr,项目名称:jbossforge-html-parser,代码行数:5,代码来源:HTMLCommentImpl.java


注:本文中的org.jsoup.nodes.Comment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。