本文整理汇总了Java中org.jsoup.select.NodeVisitor类的典型用法代码示例。如果您正苦于以下问题:Java NodeVisitor类的具体用法?Java NodeVisitor怎么用?Java NodeVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NodeVisitor类属于org.jsoup.select包,在下文中一共展示了NodeVisitor类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toNormalHtml
import org.jsoup.select.NodeVisitor; //导入依赖的package包/类
String toNormalHtml(Document doc)
{
doc.normalise();
doc.traverse(
new NodeVisitor() {
@Override
public void tail(Node node, int depth) {
if (node instanceof TextNode) {
TextNode textNode = (TextNode) node;
textNode.text(textNode.text().trim());
}
}
@Override
public void head(Node arg0, int arg1) {
}
}
);
return cleaner.clean(doc).html();
}
示例2: traverse
import org.jsoup.select.NodeVisitor; //导入依赖的package包/类
/**
* Perform a depth-first traversal through this node and its descendants.
* @param nodeVisitor the visitor callbacks to perform on each node
* @return this node, for chaining
*/
public Node traverse(NodeVisitor nodeVisitor) {
Validate.notNull(nodeVisitor);
NodeTraversor traversor = new NodeTraversor(nodeVisitor);
traversor.traverse(this);
return this;
}
示例3: traverse
import org.jsoup.select.NodeVisitor; //导入依赖的package包/类
/**
* Perform a depth-first traversal through this node and its descendants.
* @param nodeVisitor the visitor callbacks to perform on each node
* @return this node, for chaining
*/
public Node traverse(NodeVisitor nodeVisitor) {
Validate.notNull(nodeVisitor);
NodeTraversor.traverse(nodeVisitor, this);
return this;
}