當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.nextSibling方法代碼示例

本文整理匯總了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();
        }
    }
}
 
開發者ID:cpusoft,項目名稱:common,代碼行數:27,代碼來源:NodeTraversor.java

示例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;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:33,代碼來源:HtmlSignatureRemover.java

示例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;
}
 
開發者ID:yizhuoyan,項目名稱:case-html-data-gather,代碼行數:37,代碼來源:HTMLDataGather.java

示例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;
}
 
開發者ID:andyphillips404,項目名稱:awplab-core,代碼行數:11,代碼來源:JsoupSession.java

示例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());
			}
		}
	}
}
 
開發者ID:Maia-Everett,項目名稱:questfiller,代碼行數:62,代碼來源:QuestParser.java


注:本文中的org.jsoup.nodes.Node.nextSibling方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。