Example usage for org.jsoup.nodes Element nextSibling

List of usage examples for org.jsoup.nodes Element nextSibling

Introduction

In this page you can find the example usage for org.jsoup.nodes Element nextSibling.

Prototype

public Node nextSibling() 

Source Link

Document

Get this node's next sibling.

Usage

From source file:mml.handler.post.MMLPostHTMLHandler.java

/**
 * Get the next word AFTER the given element
 * @param node the node after which we seek the next word
 * @return the word//ww  w. java2  s.co m
 */
String nextWord(Element node) {
    StringBuilder word = new StringBuilder();
    Node next = node.nextSibling();
    String text = "";
    if (next != null) {
        if (next instanceof TextNode) {
            text = ((TextNode) next).text();
        } else if (next instanceof Element) {
            text = getTextOf(next);
        }
    }
    text = text.trim();
    for (int i = 0; i < text.length(); i++)
        if (!Character.isWhitespace(text.charAt(i)))
            word.append(text.charAt(i));
        else
            break;
    return word.toString();
}