Java XML Element Sibling getNextSiblingElement(Element element)

Here you can find the source of getNextSiblingElement(Element element)

Description

get Next Sibling Element

License

LGPL

Declaration

public static Element getNextSiblingElement(Element element) 

Method Source Code

//package com.java2s;
// Metawidget (licensed under LGPL)

import org.w3c.dom.Element;

import org.w3c.dom.Node;

public class Main {
    public static Element getNextSiblingElement(Element element) {

        try {//from  www. j a v  a2s  .c om
            Node node = element.getNextSibling();

            while (node != null && !(node instanceof Element)) {

                node = node.getNextSibling();
            }

            return (Element) node;

        } catch (IndexOutOfBoundsException e) {

            // Android 1.6 throws IndexOutOfBoundsException instead of correctly returning null

            return null;
        }
    }
}

Related

  1. getNextSibling(Element node, String name)
  2. getNextSiblingElement(Element el)
  3. getNextSiblingElement(Element elem)
  4. getNextSiblingElement(Element elem)
  5. getNextSiblingElement(Element element)
  6. getNextSiblingElement(Node node)
  7. getNextSiblingElementByTagName(Element e, String name)
  8. getNextSiblingElementWithName(Element elem, String name)
  9. getPrecedingSiblings(Element element, String namespaceUri)