本文整理了Java中org.jsoup.nodes.Document.appendChild()
方法的一些代码示例,展示了Document.appendChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Document.appendChild()
方法的具体详情如下:
包路径:org.jsoup.nodes.Document
类名称:Document
方法名:appendChild
暂无
代码示例来源:origin: code4craft/webmagic
/**
* Only document can be select
* See: https://github.com/code4craft/webmagic/issues/113
*
* @param elementIterator elementIterator
* @return element element
*/
private Element checkElementAndConvert(ListIterator<Element> elementIterator) {
Element element = elementIterator.next();
if (!(element instanceof Document)) {
Document root = new Document(element.ownerDocument().baseUri());
Element clone = element.clone();
root.appendChild(clone);
elementIterator.set(root);
return root;
}
return element;
}
代码示例来源:origin: org.jsoup/jsoup
private void insertNode(Node node) {
// if the stack hasn't been set up yet, elements (doctype, comments) go into the doc
if (stack.size() == 0)
doc.appendChild(node);
else if (isFosterInserts())
insertInFosterParent(node);
else
currentElement().appendChild(node);
// connect form controls to their form element
if (node instanceof Element && ((Element) node).tag().isFormListed()) {
if (formElement != null)
formElement.addElement((Element) node);
}
}
代码示例来源:origin: org.jsoup/jsoup
doc.appendChild(root);
stack.add(root);
resetInsertionMode();
代码示例来源:origin: org.jsoup/jsoup
boolean process(Token t, HtmlTreeBuilder tb) {
if (isWhitespace(t)) {
return true; // ignore whitespace
} else if (t.isComment()) {
tb.insert(t.asComment());
} else if (t.isDoctype()) {
// todo: parse error check on expected doctypes
// todo: quirk state check on doctype ids
Token.Doctype d = t.asDoctype();
DocumentType doctype = new DocumentType(
tb.settings.normalizeTag(d.getName()), d.getPublicIdentifier(), d.getSystemIdentifier());
doctype.setPubSysKey(d.getPubSysKey());
tb.getDocument().appendChild(doctype);
if (d.isForceQuirks())
tb.getDocument().quirksMode(Document.QuirksMode.quirks);
tb.transition(BeforeHtml);
} else {
// todo: check not iframe srcdoc
tb.transition(BeforeHtml);
return tb.process(t); // re-process token
}
return true;
}
},
代码示例来源:origin: com.vaadin/vaadin-server
doc.appendChild(docType);
Element html = doc.createElement("html");
doc.appendChild(html);
html.appendChild(doc.createElement("head"));
Element body = doc.createElement("body");
代码示例来源:origin: org.aperteworkflow/webapi
private void addVersionNumber(Document document) {
Element versionNumber = document.createElement("div")
.attr("id", "versionList")
.attr("class", "process-version");
document.appendChild(versionNumber);
versionNumber.append(description + " v. " + version);
}
代码示例来源:origin: org.aperteworkflow/webapi
public StringBuilder build() throws Exception {
final StringBuilder stringBuilder = new StringBuilder(8 * 1024);
scriptBuilder.append("<script type=\"text/javascript\">");
final Document document = Jsoup.parse("");
if (!hasUserPriviledgesToViewTask()) {
final Element widgetsNode = document.createElement("div")
.attr("role", "alert")
.attr("class", "alert alert-warning");
widgetsNode.text(i18Source.getMessage("task.noright.to.view"));
document.appendChild(widgetsNode);
stringBuilder.append(document.toString());
return stringBuilder;
}
if (showGenericButtons())
buildActionButtons(document);
final Element widgetsNode = document.createElement("div")
.attr("id", getVaadinWidgetsHtmlId())
.attr("class", "vaadin-widgets-view");
document.appendChild(widgetsNode);
buildWidgets(document, widgetsNode);
buildAdditionalData(document);
stringBuilder.append(document.toString());
scriptBuilder.append("vaadinWidgetsCount = ").append(vaadinWidgetsCount).append(';');
scriptBuilder.append("</script>");
stringBuilder.append(scriptBuilder);
return stringBuilder;
}
代码示例来源:origin: com.cv4j.netdiscovery/netdiscovery-core
/**
* Only document can be select
* See: https://github.com/code4craft/webmagic/issues/113
*
* @param elementIterator elementIterator
* @return element element
*/
private Element checkElementAndConvert(ListIterator<Element> elementIterator) {
Element element = elementIterator.next();
if (!(element instanceof Document)) {
Document root = new Document(element.ownerDocument().baseUri());
Element clone = element.clone();
root.appendChild(clone);
elementIterator.set(root);
return root;
}
return element;
}
代码示例来源:origin: us.codecraft/webmagic-core
/**
* Only document can be select
* See: https://github.com/code4craft/webmagic/issues/113
*
* @param elementIterator elementIterator
* @return element element
*/
private Element checkElementAndConvert(ListIterator<Element> elementIterator) {
Element element = elementIterator.next();
if (!(element instanceof Document)) {
Document root = new Document(element.ownerDocument().baseUri());
Element clone = element.clone();
root.appendChild(clone);
elementIterator.set(root);
return root;
}
return element;
}
代码示例来源:origin: apache/archiva
res.appendChild( body.select( "div[id=main]" ).first() );
res.appendChild( script );
代码示例来源:origin: org.apache.archiva/archiva-web-common
res.appendChild( body.select( "div[id=main]" ).first() );
res.appendChild( script );
代码示例来源:origin: astamuse/asta4d
public String toHtml() {
Document doc = new Document("");
doc.appendChild(toElement());
RenderUtil.applyMessages(doc);
RenderUtil.applyClearAction(doc, true);
return doc.html();
}
代码示例来源: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: astamuse/asta4d
private void insertNode(Node node) {
// if the stack hasn't been set up yet, elements (doctype, comments) go into the doc
if (stack.size() == 0)
doc.appendChild(node);
else if (isFosterInserts())
insertInFosterParent(node);
else
currentElement().appendChild(node);
// connect form controls to their form element
if (node instanceof Element && ((Element) node).tag().isFormListed()) {
if (formElement != null)
formElement.addElement((Element) node);
}
}
代码示例来源:origin: com.vaadin/flow-server
DocumentType doctype = new DocumentType("html", "", "",
document.baseUri());
document.appendChild(doctype);
Element html = document.appendElement("html");
html.attr("lang", context.getUI().getLocale().getLanguage());
代码示例来源:origin: chimbori/crux
static Document postprocess(Element topNode) {
Log.i("postprocess");
Document doc = new Document("");
if (topNode == null) {
return doc;
}
removeNodesWithNegativeScores(topNode);
replaceLineBreaksWithSpaces(topNode);
removeUnlikelyChildNodes(topNode);
removeTagsButRetainContent(topNode);
removeTagsNotLikelyToBeParagraphs(topNode);
removeTopLevelTagsNotLikelyToBeParagraphs(topNode);
removeShortParagraphs(topNode);
removeDisallowedAttributes(topNode);
for (Node node : topNode.childNodes()) {
doc.appendChild(node.clone()); // TODO: Don’t copy each item separately.
}
return doc;
}
代码示例来源:origin: astamuse/asta4d
doc.appendChild(root);
stack.push(root);
resetInsertionMode();
代码示例来源:origin: astamuse/asta4d
boolean process(Token t, Asta4DTagSupportHtmlTreeBuilder tb) {
if (isWhitespace(t)) {
return true; // ignore whitespace
} else if (t.isComment()) {
tb.insert(t.asComment());
} else if (t.isDoctype()) {
// todo: parse error check on expected doctypes
// todo: quirk state check on doctype ids
Token.Doctype d = t.asDoctype();
DocumentType doctype = new DocumentType(d.getName(), d.getPublicIdentifier(), d.getSystemIdentifier(), tb.getBaseUri());
tb.getDocument().appendChild(doctype);
if (d.isForceQuirks())
tb.getDocument().quirksMode(Document.QuirksMode.quirks);
tb.transition(BeforeHtml);
} else {
// todo: check not iframe srcdoc
tb.transition(BeforeHtml);
return tb.process(t); // re-process token
}
return true;
}
},
内容来源于网络,如有侵权,请联系作者删除!