org.jsoup.parser.Tag.isKnownTag()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.jsoup.parser.Tag.isKnownTag()方法的一些代码示例,展示了Tag.isKnownTag()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tag.isKnownTag()方法的具体详情如下:
包路径:org.jsoup.parser.Tag
类名称:Tag
方法名:isKnownTag

Tag.isKnownTag介绍

[英]Get if this is a pre-defined tag, or was auto created on parsing.
[中]获取这是预定义的标记,还是在解析时自动创建的标记。

代码示例

代码示例来源:origin: org.jsoup/jsoup

Element insert(Token.StartTag startTag) {
  Tag tag = Tag.valueOf(startTag.name(), settings);
  // todo: wonder if for xml parsing, should treat all tags as unknown? because it's not html.
  Element el = new Element(tag, baseUri, settings.normalizeAttributes(startTag.attributes));
  insertNode(el);
  if (startTag.isSelfClosing()) {
    if (!tag.isKnownTag()) // unknown tag, remember this is self closing for output. see above.
      tag.setSelfClosing();
  } else {
    stack.add(el);
  }
  return el;
}

代码示例来源:origin: org.jsoup/jsoup

Element insertEmpty(Token.StartTag startTag) {
  Tag tag = Tag.valueOf(startTag.name(), settings);
  Element el = new Element(tag, baseUri, startTag.attributes);
  insertNode(el);
  if (startTag.isSelfClosing()) {
    if (tag.isKnownTag()) {
      if (!tag.isEmpty())
        tokeniser.error("Tag cannot be self closing; not a void tag");
    }
    else // unknown tag, remember this is self closing for output
      tag.setSelfClosing();
  }
  return el;
}

代码示例来源:origin: abola/CrawlerPack

Element insert(StartTag startTag) {
  // remove prefix
  Tag tag = Tag.valueOf(startTag.name().replace(this.prefix,""));
  Element el = new Element(tag, this.baseUri, startTag.attributes);
  this.insertNode(el);
  if(startTag.isSelfClosing()) {
    this.tokeniser.acknowledgeSelfClosingFlag();
    if(!tag.isKnownTag()) {
      tag.setSelfClosing();
    }
  } else {
    this.stack.add(el);
  }
  return el;
}

代码示例来源:origin: astamuse/asta4d

Element insertEmpty(Token.StartTag startTag) {
  Tag tag = Tag.valueOf(startTag.name());
  Element el = new Element(tag, baseUri, startTag.attributes);
  insertNode(el);
  if (startTag.isSelfClosing()) {
    if (tag.isKnownTag()) {
      if (tag.isSelfClosing())
        tokeniser.acknowledgeSelfClosingFlag(); // if not acked, promulagates error
    } else {
      // unknown tag, remember this is self closing for output
      tag.setSelfClosing();
      tokeniser.acknowledgeSelfClosingFlag(); // not an distinct error
    }
  }
  return el;
}

相关文章