gpt4 book ai didi

org.jsoup.nodes.XmlDeclaration.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 05:12:40 27 4
gpt4 key购买 nike

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

XmlDeclaration.<init>介绍

[英]Create a new XML declaration
[中]创建新的XML声明

代码示例

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

void insert(Token.Comment commentToken) {
  Comment comment = new Comment(commentToken.getData());
  Node insert = comment;
  if (commentToken.bogus) { // xml declarations are emitted as bogus comments (which is right for html, but not xml)
    // so we do a bit of a hack and parse the data as an element to pull the attributes out
    String data = comment.getData();
    if (data.length() > 1 && (data.startsWith("!") || data.startsWith("?"))) {
      Document doc = Jsoup.parse("<" + data.substring(1, data.length() -1) + ">", baseUri, Parser.xmlParser());
      if (doc.childNodeSize() > 0) {
        Element el = doc.child(0);
        insert = new XmlDeclaration(settings.normalizeTag(el.tagName()), data.startsWith("!"));
        insert.attributes().addAll(el.attributes());
      } // else, we couldn't parse it as a decl, so leave as a comment
    }
  }
  insertNode(insert);
}

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

decl = new XmlDeclaration("xml", false);
  decl.attr("version", "1.0");
  decl.attr("encoding", charset().displayName());
XmlDeclaration decl = new XmlDeclaration("xml", false);
decl.attr("version", "1.0");
decl.attr("encoding", charset().displayName());

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

void insert(Comment commentToken) {
  org.jsoup.nodes.Comment comment = new org.jsoup.nodes.Comment(commentToken.getData(), this.baseUri);
  Object insert = comment;
  if(commentToken.bogus) {
    String data = comment.getData();
    if(data.length() > 1 && (data.startsWith("!") || data.startsWith("?"))) {
      String declaration = data.substring(1);
      insert = new XmlDeclaration(declaration, comment.baseUri(), data.startsWith("!"));
    }
  }
  this.insertNode((Node)insert);
}

代码示例来源:origin: br.com.objectos/sitebricks

private void parseXmlDecl() {
 tq.consume("<");
 Character firstChar = tq.consume(); // <? or <!, from initial match.
 boolean procInstr = firstChar.toString().equals("!");
 String data = tq.chompTo(">");
 XmlDeclaration decl = new XmlDeclaration(data, baseUri, procInstr);
 annotate(decl); // TODO - should annotations even apply to declarations?
 lines(decl, data);
 add(decl);
}

代码示例来源:origin: com.google.sitebricks/sitebricks

private void parseXmlDecl() {
 tq.consume("<");
 Character firstChar = tq.consume(); // <? or <!, from initial match.
 boolean procInstr = firstChar.toString().equals("!");
 String data = tq.chompTo(">");
 XmlDeclaration decl = new XmlDeclaration(data, baseUri, procInstr);
 annotate(decl); // TODO - should annotations even apply to declarations?
 lines(decl, data);
 add(decl);
}

代码示例来源:origin: dhanji/sitebricks

private void parseXmlDecl() {
 tq.consume("<");
 Character firstChar = tq.consume(); // <? or <!, from initial match.
 boolean procInstr = firstChar.toString().equals("!");
 String data = tq.chompTo(">");
 XmlDeclaration decl = new XmlDeclaration(data, baseUri, procInstr);
 annotate(decl); // TODO - should annotations even apply to declarations?
 lines(decl, data);
 add(decl);
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com