本文整理汇总了Java中org.jsoup.nodes.Node.nextSibling方法的典型用法代码示例。如果您正苦于以下问题:Java Node.nextSibling方法的具体用法?Java Node.nextSibling怎么用?Java Node.nextSibling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.nodes.Node
的用法示例。
在下文中一共展示了Node.nextSibling方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: traverse
import org.jsoup.nodes.Node; //导入方法依赖的package包/类
/**
* Start a depth-first traverse of the root and all of its descendants.
* @param root the root node point to traverse.
*/
public void traverse(Node root) {
Node node = root;
int depth = 0;
while (node != null) {
visitor.head(node, depth);
if (node.childNodeSize() > 0) {
node = node.childNode(0);
depth++;
} else {
while (node.nextSibling() == null && depth > 0) {
visitor.tail(node, depth);
node = node.parentNode();
depth--;
}
visitor.tail(node, depth);
if (node == root)
break;
node = node.nextSibling();
}
}
}
示例2: head
import org.jsoup.nodes.Node; //导入方法依赖的package包/类
@NonNull
@Override
public HeadFilterDecision head(Node node, int depth) {
if (signatureFound) {
return HeadFilterDecision.REMOVE;
}
if (node instanceof Element) {
lastElementCausedLineBreak = false;
Element element = (Element) node;
if (element.tag().equals(BLOCKQUOTE)) {
return HeadFilterDecision.SKIP_ENTIRELY;
}
} else if (node instanceof TextNode) {
TextNode textNode = (TextNode) node;
if (lastElementCausedLineBreak && DASH_SIGNATURE_HTML.matcher(textNode.getWholeText()).matches()) {
Node nextNode = node.nextSibling();
if (nextNode instanceof Element && ((Element) nextNode).tag().equals(BR)) {
signatureFound = true;
if (brElementPrecedingDashes != null) {
brElementPrecedingDashes.remove();
brElementPrecedingDashes = null;
}
return HeadFilterDecision.REMOVE;
}
}
}
return HeadFilterDecision.CONTINUE;
}
示例3: gatherDuyins
import org.jsoup.nodes.Node; //导入方法依赖的package包/类
private List<DuYinDM> gatherDuyins(Element contentEL)throws Exception{
Elements elements=contentEL.select("p");
DuYinDM dm=null;
List<DuYinDM> results=new ArrayList<DuYinDM>(3);
for (Element p : elements) {
if(p.children().isEmpty())continue;
Element firstChild=p.child(0);
if("span".equals(firstChild.tagName())){
if(firstChild.hasClass("dicpy")){
if(dm!=null){
results.add(dm);
}
dm=new DuYinDM();
String duyin=firstChild.text();
dm.setDuyin(duyin);
}
}else if("em".equals(firstChild.tagName())){
StringBuilder ziyi=new StringBuilder();
Node next=firstChild.nextSibling();
while(next!=null){
if(next instanceof TextNode){
ziyi.append(((TextNode) next).text());
}else if(next instanceof Element){
ziyi.append(((Element) next).text());
}
next=next.nextSibling();
}
dm.addZiyi(ziyi.toString());
}
}
if(dm!=null){
results.add(dm);
}
return results;
}
示例4: getNextNonEmptyNode
import org.jsoup.nodes.Node; //导入方法依赖的package包/类
public Node getNextNonEmptyNode(Node input) {
if (input == null) return null;
Node sibling = input.nextSibling();
if (sibling == null) return null;
if (sibling instanceof TextNode && ((TextNode) sibling).text().replaceAll("\u00A0", " ").trim().length() == 0) {
return getNextNonEmptyNode(sibling);
}
return sibling;
}
示例5: parseObjectives
import org.jsoup.nodes.Node; //导入方法依赖的package包/类
private void parseObjectives(final Quest quest, final Element mainContainer, final Element questName) {
// Objectives section
Node objectivesNode = questName.nextSibling();
// Objectives text is the first non-empty text node immediately following the header
while (!(objectivesNode instanceof TextNode) || ((TextNode) objectivesNode).text().trim().isEmpty()) {
objectivesNode = objectivesNode.nextSibling();
}
final Node beforeObjectives = objectivesNode.previousSibling();
// If there is a h2.heading-size-3 right before the "objectives" text, it is probably not objectives,
// but rather progress or completion, like on the quest "Draenei Tail"
if (!(beforeObjectives instanceof Element && ((Element) beforeObjectives).tagName().equals("h2")
&& ((Element) beforeObjectives).hasClass("heading-size-3"))) {
quest.setObjectives(((TextNode) objectivesNode).text().trim());
}
// Objective completion stages
final Elements iconlists = mainContainer.select("table.iconlist");
final Element stagesTable = iconlists.first();
if (stagesTable != null) {
// Remove any subtables
stagesTable.select("table.iconlist").remove();
for (final Element stageLink : stagesTable.getElementsByTag("a")) {
// Find the innermost td element enclosing the a, and add its whole text
Element parent = stageLink.parent();
while (!parent.tagName().equals("td")) {
parent = parent.parent();
}
quest.getStages().add(parent.text());
}
// Suggested players
final Element suggestedPlayers = stagesTable.getElementsContainingOwnText("Suggested players:").first();
if (suggestedPlayers != null) {
String playerCountStr =
getRegexGroup(suggestedPlayers.ownText(), "Suggested players: ([0-9]+)", 1).get();
quest.setGroupSize(Integer.parseInt(playerCountStr));
}
}
// Provided items
if (iconlists.size() >= 2) {
final Element maybeProvided = iconlists.get(1);
final Node before = maybeProvided.previousSibling();
if (before instanceof TextNode && ((TextNode) before).text().contains("Provided")) {
maybeProvided.select("table.iconlist").remove();
for (final Element itemLink : maybeProvided.getElementsByTag("a")) {
quest.getProvidedItems().add(itemLink.text());
}
}
}
}