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

x33g5p2x  于2022-01-18 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(178)

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

Document.appendElement介绍

暂无

代码示例

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

/**
 Create a valid, empty shell of a document, suitable for adding more elements to.
 @param baseUri baseUri of document
 @return document with html, head, and body elements.
 */
public static Document createShell(String baseUri) {
  Validate.notNull(baseUri);
  Document doc = new Document(baseUri);
  Element html = doc.appendElement("html");
  html.appendElement("head");
  html.appendElement("body");
  return doc;
}

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

/**
 Normalise the document. This happens after the parse phase so generally does not need to be called.
 Moves any text content that is not in the body element into the body.
 @return this document after normalisation
 */
public Document normalise() {
  Element htmlEl = findFirstElementByTagName("html", this);
  if (htmlEl == null)
    htmlEl = appendElement("html");
  if (head() == null)
    htmlEl.prependElement("head");
  if (body() == null)
    htmlEl.appendElement("body");
  // pull text nodes out of root, html, and head els, and push into body. non-text nodes are already taken care
  // of. do in inverse order to maintain text order.
  normaliseTextNodes(head());
  normaliseTextNodes(htmlEl);
  normaliseTextNodes(this);
  normaliseStructure("head", htmlEl);
  normaliseStructure("body", htmlEl);
  
  ensureMetaCharsetElement();
  
  return this;
}

代码示例来源:origin: stackoverflow.com

import org.jsoup.nodes.*;

Document doc = Jsoup.parse("");
// clear <html><body></body></html>
doc.html("");

Element e = doc.appendElement("body").appendElement("resources");

e = e.appendElement("string-array");
e.attr("name", "mytest");

for (int i = 0; i < 10; i++) {
  Element sub = e.appendElement("item");
  sub.attr("number", Integer.toString(i));
  sub.appendElement("name").text("blahh");
}

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

public Component(Element elem, AttributesRequire attrs) throws Exception {
  Document doc = new Document("");
  doc.appendElement("body");
  doc.body().appendChild(elem);
  renderedElement = renderTemplate(doc, attrs);
}

代码示例来源:origin: basis-technology-corp/Java-readability

private void prepDocument() {
  /**
   * In some cases a body element can't be found (if the HTML is totally hosed for example) so we create
   * a new body node and append it to the document.
   */
  if (body == null) {
    body = document.appendElement("body");
  }
  body.attr("id", "readabilityBody");
  Elements frames = document.getElementsByTag("frame");
  if (frames.size() > 0) {
    LOG.error("Frames. Can't deal. Write code later to look at URLs and fetch");
    impossible = true;
    return;
  }
  Elements stylesheets = document.getElementsByTag("style");
  stylesheets.remove();
  stylesheets = document.select("link[rel='stylesheet']");
  stylesheets.remove();
  /* Turn all double br's into p's */
  /*
   * Note, this is pretty costly as far as processing goes. Maybe optimize later.
   */
  handlePP();
  handleDoubleBr();
  fontsToSpans();
}

代码示例来源:origin: org.aperteworkflow/webapi

/**
 * Add actions buttons to the output document.
 */
protected void buildActionButtons(final Document document) {
  Element actionsNode = document.createElement("div")
      //.attr("id", "actions-list")
      .attr("id", getActionsListHtmlId())
      .attr("class", "actions-view")
      .addClass("fixed-element-action-buttons");
  document.appendChild(actionsNode);
  Element genericActionButtons = document.createElement("div")
      .attr("id", getActionsGenericListHtmlId())
      .attr("class", "btn-group  pull-left actions-generic-view");
  Element specificActionButtons = document.createElement("div")
      .attr("id", getActionsSpecificListHtmlId())
      .attr("class", "btn-group  pull-right actions-process-view");
  actionsNode.appendChild(genericActionButtons);
  actionsNode.appendChild(specificActionButtons);
  document.appendElement("div").addClass("fixed-element-anchor-action-buttons");
  /* Check if the viewed object is in a terminal state */
  buildGenericActionButtons(genericActionButtons);
  if (!isViewedObjectClosed()) {
    buildSpecificActionButtons(specificActionButtons);
  }
}

代码示例来源:origin: wuman/JReadability

mDocument.appendElement("body");

代码示例来源:origin: com.vaadin/flow-server

document.baseUri());
document.appendChild(doctype);
Element html = document.appendElement("html");
html.attr("lang", context.getUI().getLocale().getLanguage());
Element head = html.appendElement("head");

相关文章