Java Utililty Methods XML Node Sibiling

List of utility methods to do XML Node Sibiling

Description

The list of methods to do XML Node Sibiling are organized into topic(s).

Method

NodegetNextNodeSibling(Node node)
Get the next non-text sibling after a node.
Node sibling = node.getNextSibling();
while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE)
    sibling = sibling.getNextSibling();
return sibling;
NodegetNextSibling(Node node)
get Next Sibling
Node sibling = node.getNextSibling();
while (sibling != null && isWhitespace(sibling)) {
    sibling = sibling.getNextSibling();
return sibling;
ElementgetNextSiblingElement(Node n)
Gets the next sibling Element of the node, skipping any Text nodes such as whitespace.
Node sib = n.getNextSibling();
while (sib != null && sib.getNodeType() != Node.ELEMENT_NODE) {
    sib = sib.getNextSibling();
if (sib != null) {
    return (Element) sib;
} else {
    return null;
...
ElementgetNextSiblingElement(Node n, String ns, String localName)
Gets the next sibling Element of the node of the given name, skipping any Text nodes such as whitespace.
Element e = getNextSiblingElement(n);
while (e != null && !isElementNamed(e, ns, localName))
    e = getNextSiblingElement(e);
return e;
ElementgetNextSiblingElement(Node node)
get Next Sibling Element
Node nextSibling = node.getNextSibling();
while (nextSibling != null) {
    if (nextSibling.getNodeType() == Node.ELEMENT_NODE) {
        return (Element) nextSibling;
    nextSibling = nextSibling.getNextSibling();
return null;
...
ElementgetNextSiblingElement(Node node)
Get the next sibling Element of the supplied node.
Node sibling = node.getNextSibling();
while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE) {
    sibling = sibling.getNextSibling();
return (Element) sibling;
ElementgetNextSiblingElement(Node node)
Gets the next sibling of a node that is an element.
do {
    node = node.getNextSibling();
} while (node != null && node.getNodeType() != Node.ELEMENT_NODE);
return (Element) node;
ElementgetNextSiblingElement(Node node)
get Next Sibling Element
node = node.getNextSibling();
while (node != null) {
    if (node.getNodeType() == Node.ELEMENT_NODE) {
        return (Element) node;
    node = node.getNextSibling();
return null;
...
ElementgetNextSiblingElement(Node node)
Returns the next sibling element of the specified node.
Node sibling = node.getNextSibling();
if ((sibling == null) || (sibling.getNodeType() == Node.ELEMENT_NODE)) {
    return (Element) sibling;
return getNextSiblingElement(sibling);
NodegetNextSiblingElement(Node node)
get Next Sibling Element
if (node == null || node.getParentNode() == null) {
    return null;
Node parent = node.getParentNode();
NodeList nodes = parent.getChildNodes();
if (nodes == null) {
    return null;
boolean found = false;
for (int i = 0; i < nodes.getLength(); i++) {
    Node child = nodes.item(i);
    if (child.equals(node)) {
        found = true;
        continue;
    if (found && child.getNodeType() == Node.ELEMENT_NODE) {
        return child;
return null;