本文整理了Java中org.jsoup.nodes.Element.traverse()
方法的一些代码示例,展示了Element.traverse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.traverse()
方法的具体详情如下:
包路径:org.jsoup.nodes.Element
类名称:Element
方法名:traverse
暂无
代码示例来源:origin: astamuse/asta4d
public Node traverse(NodeVisitor nodeVisitor) {
return originElement.traverse(nodeVisitor);
}
代码示例来源:origin: com.vaadin/flow-server
private void inspectTwoWayBindings(org.jsoup.nodes.Element element) {
Matcher matcher = TWO_WAY_BINDING_PATTERN.matcher("");
element.traverse(new NodeVisitor() {
@Override
public void head(Node node, int depth) {
// Two way bindings should only be in property bindings, not
// inside text content.
for (Attribute attribute : node.attributes()) {
String value = attribute.getValue();
//It is legal for attributes in templates not to have values,
//which is a short form for giving the attribute the value 'true'.
//These attributes don't contain bindings (they're just 'true'), so we
//skip them.
if (value == null) {
continue;
}
matcher.reset(value);
if (matcher.matches()) {
String path = matcher.group(1);
addTwoWayBindingPath(path);
}
}
}
@Override
public void tail(Node node, int depth) {
// Nop
}
});
}
代码示例来源:origin: cn.edu.hfut.dmic.webcollector/WebCollector
protected String getTitleByEditDistance(Element contentElement) throws Exception {
final String metaTitle = doc.title();
final ArrayList<Double> max = new ArrayList<Double>();
max.add(0.0);
final StringBuilder sb = new StringBuilder();
doc.body().traverse(new NodeVisitor() {
public void head(Node node, int i) {
if (node instanceof TextNode) {
TextNode tn = (TextNode) node;
String text = tn.text().trim();
double sim = strSim(text, metaTitle);
if (sim > 0) {
if (sim > max.get(0)) {
max.set(0, sim);
sb.setLength(0);
sb.append(text);
}
}
}
}
public void tail(Node node, int i) {
}
});
if (sb.length() > 0) {
return sb.toString();
}
throw new Exception();
}
代码示例来源:origin: io.committed.krill/krill
private void convertLists(final Document document) {
// Convert p tags which start with a dot into listitems
document.select("p").forEach(e -> {
final String text = e.text();
for (final String symbol : LISTITEM_SYMBOLS) {
if (text.startsWith(symbol)) {
e.tagName("li");
}
}
});
// Under an ul or ol should be a li
document.select("ul,ol > p").forEach(l -> l.select("p").wrap("<li></li>"));
// If not parent of li if not ul or ol then wrap with ul?
wrapRunsOfChildTag(document, "li",
p -> "ul".equalsIgnoreCase(p.tagName()) || "ol".equalsIgnoreCase(p.tagName()), "ul");
// Remove the prefix on the list items
document.select("li").forEach(
element -> element.traverse(new RemovePrefixFromListItemNodeVisitor(LISTITEM_SYMBOLS)));
}
代码示例来源:origin: cn.edu.hfut.dmic.webcollector/WebCollector
final String metaTitle = doc.title().trim();
if (!metaTitle.isEmpty()) {
doc.body().traverse(new NodeVisitor() {
@Override
public void head(Node node, int i) {
代码示例来源:origin: io.committed.krill/krill
/**
* Convert paragraphs which are lists into HTML list and list item types.
*
* @param document
* the document
*/
private void convertLists(final Document document) {
// Correct paragraph tags
document.select("p.list_paragraph,p.list_Paragraph").tagName("li").removeAttr(CLASS);
// Convert p tags which start with a dot into listitems
document.select("p").forEach(e -> {
if (e.text().startsWith(DOT)) {
e.tagName("li");
}
});
// Under an ul or ol should be a li
document.select("ul,ol > p").forEach(l -> l.select("p").wrap("<li></li>"));
// If not parent of li if not ul or ol then wrap with ul?
wrapRunsOfChildTag(document, "li",
p -> "ul".equalsIgnoreCase(p.tagName()) || "ol".equalsIgnoreCase(p.tagName()), "ul");
// Remove the prefix on the list items
document.select("li")
.forEach(element -> element.traverse(new RemovePrefixFromListItemNodeVisitor(DOT)));
}
代码示例来源:origin: de.unistuttgart.ims/de.unistuttgart.ims.drama.io.core
root.traverse(vis);
jcas = vis.getJCas();
代码示例来源:origin: de.unistuttgart.ims/uimautil
root.traverse(vis);
代码示例来源:origin: de.unistuttgart.ims.uima.io/generic-xml-reader
root.traverse(vis);
内容来源于网络,如有侵权,请联系作者删除!