Java XML Node Sibiling getNextSiblingElement(Node node)

Here you can find the source of getNextSiblingElement(Node node)

Description

Returns the next sibling element of the specified node.

License

BSD License

Parameter

Parameter Description
node the node to process.

Return

the next sibling element of the specified node.

Declaration

public static Element getNextSiblingElement(Node node) 

Method Source Code


//package com.java2s;
/*//from  www .j a  v  a2 s.  co  m
 * Copyright (c) 2012. betterFORM Project - http://www.betterform.de
 * Licensed under the terms of BSD License
 */

import org.w3c.dom.*;

public class Main {
    /**
     * Returns the next sibling element of the specified node.
     * <p/>
     * If there is no such element, this method returns <code>null</code>.
     *
     * @param node the node to process.
     * @return the next sibling element of the specified node.
     */
    public static Element getNextSiblingElement(Node node) {
        Node sibling = node.getNextSibling();

        if ((sibling == null) || (sibling.getNodeType() == Node.ELEMENT_NODE)) {
            return (Element) sibling;
        }

        return getNextSiblingElement(sibling);
    }
}

Related

  1. getNextSiblingElement(Node n, String ns, String localName)
  2. getNextSiblingElement(Node node)
  3. getNextSiblingElement(Node node)
  4. getNextSiblingElement(Node node)
  5. getNextSiblingElement(Node node)
  6. getNextSiblingElement(Node node)
  7. getNextSiblingElement(Node node)
  8. getNextSiblingElement(Node node)
  9. getNextSiblingElement(Node node, String elemNames[])