本文整理了Java中org.jsoup.nodes.Element.prependChild()
方法的一些代码示例,展示了Element.prependChild()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.prependChild()
方法的具体详情如下:
包路径:org.jsoup.nodes.Element
类名称:Element
方法名:prependChild
[英]Add a node to the start of this element's children.
[中]将节点添加到此元素子元素的开头。
代码示例来源:origin: org.jsoup/jsoup
/**
* Create and prepend a new TextNode to this element.
*
* @param text the unencoded text to add
* @return this element
*/
public Element prependText(String text) {
Validate.notNull(text);
TextNode node = new TextNode(text);
prependChild(node);
return this;
}
代码示例来源:origin: org.jsoup/jsoup
private void normaliseTextNodes(Element element) {
List<Node> toMove = new ArrayList<>();
for (Node node: element.childNodes) {
if (node instanceof TextNode) {
TextNode tn = (TextNode) node;
if (!tn.isBlank())
toMove.add(tn);
}
}
for (int i = toMove.size()-1; i >= 0; i--) {
Node node = toMove.get(i);
element.removeChild(node);
body().prependChild(new TextNode(" "));
body().prependChild(node);
}
}
代码示例来源:origin: org.jsoup/jsoup
/**
* Create a new element by tag name, and add it as the first child.
*
* @param tagName the name of the tag (e.g. {@code div}).
* @return the new element, to allow you to add content to it, e.g.:
* {@code parent.prependElement("h1").attr("id", "header").text("Welcome");}
*/
public Element prependElement(String tagName) {
Element child = new Element(Tag.valueOf(tagName), baseUri());
prependChild(child);
return child;
}
代码示例来源:origin: astamuse/asta4d
public Element prependChild(Node child) {
return originElement.prependChild(child);
}
代码示例来源:origin: andriusvelykis/reflow-maven-skin
body.prependChild(elements.get(index));
代码示例来源:origin: lt.velykis.maven.skins/reflow-velocity-tools
body.prependChild(elements.get(index));
代码示例来源:origin: Cognifide/knotx
private void addHiddenInputTag(Element form, String formIdAttrName, String formIdAttrValue) {
Attributes attributes = Stream.of(
new Attribute("type", "hidden"),
new Attribute("name", formIdAttrName),
new Attribute("value", formIdAttrValue))
.collect(Attributes::new, Attributes::put, Attributes::addAll);
form.prependChild(new Element(Tag.valueOf("input"), "/", attributes));
}
代码示例来源:origin: com.wandrell.velocity/maven-site-fixer
/**
* Corrects table headers by adding a {@code <thead>} section where missing.
* <p>
* This serves to fix an error with tables created by Doxia, which will add
* the header rows into the {@code <tbody>} element, instead on a {@code
* <thead>} element.
*
* @param root
* root element with tables to fix
*/
public final void updateTableHeads(final Element root) {
final Iterable<Element> tableHeadRows; // Heads to fix
Element table; // HTML table
Element thead; // Table's head for wrapping
checkNotNull(root, "Received a null pointer as root element");
// Table rows with <th> tags in a <tbody>
tableHeadRows = root.select("table > tbody > tr:has(th)");
for (final Element row : tableHeadRows) {
// Gets the row's table
// The selector ensured the row is inside a tbody
table = row.parent().parent();
// Removes the row from its original position
row.remove();
// Creates a table header element with the row
thead = new Element(Tag.valueOf("thead"), "");
thead.appendChild(row);
// Adds the head at the beginning of the table
table.prependChild(thead);
}
}
代码示例来源:origin: andriusvelykis/reflow-maven-skin
thead.appendChild(row);
table.prependChild(thead);
代码示例来源:origin: lt.velykis.maven.skins/reflow-velocity-tools
thead.appendChild(row);
table.prependChild(thead);
代码示例来源:origin: perfectsense/dari
paragraph.prependChild(child.clone());
body.prependChild(lastParagraph);
代码示例来源:origin: perfectsense/brightspot-cms
paragraph.prependChild(child.clone());
body.prependChild(lastParagraph);
代码示例来源:origin: wuman/JReadability
mDocument.body().prependChild(overlay);
内容来源于网络,如有侵权,请联系作者删除!