Java Utililty Methods XML Element Sibling

List of utility methods to do XML Element Sibling

Description

The list of methods to do XML Element Sibling are organized into topic(s).

Method

intcountPrecedingSiblingsOfType(Element inElem)
count Preceding Siblings Of Type
int cnt = 1; 
Node node = inElem.getPreviousSibling();
String typeName = inElem.getNodeName();
while (node != null) {
    while (node.getNodeType() != Node.ELEMENT_NODE) {
        node = node.getPreviousSibling();
        if (node == null) {
            break;
...
ElementgetNextElementSibling(Element aElement)
Gets the next sibling Element of a provided Element.
Element theSibling = null;
Node theCurrNode = aElement;
while ((theCurrNode != null) && (theSibling == null)) {
    theCurrNode = theCurrNode.getNextSibling();
    if ((theCurrNode != null) && (theCurrNode.getNodeType() == Node.ELEMENT_NODE)) {
        theSibling = (Element) theCurrNode;
return theSibling;
ElementgetNextSibling(Element element)
Get the next sibling element.
return findNextSibling(element.getNextSibling());
ElementgetNextSibling(Element h2)
get Next Sibling
Node node = h2.getNextSibling();
while (node != null && node.getNodeType() != Node.ELEMENT_NODE) {
    node = node.getNextSibling();
return getElement(node);
ElementgetNextSibling(Element node, String name)
Get the next sibling element with the given name.
final String filter = (name != null && !name.equals("*")) ? name : null;
for (Node n = node.getNextSibling(); n != null; n = n.getNextSibling()) {
    if (n.getNodeType() == Node.ELEMENT_NODE && (filter == null || n.getNodeName().equals(filter)))
        return (Element) n;
return null;
ElementgetNextSiblingElement(Element el)
Get the next sibling element
for (Node n = el.getNextSibling(); n != null; n = n.getNextSibling()) {
    if (n instanceof Element) {
        return (Element) n;
return null;
ElementgetNextSiblingElement(Element elem)
Return the next sibling element of the given element.
for (Node n = elem.getNextSibling(); n != null; n = n.getNextSibling()) {
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        return (Element) n;
return null;
ElementgetNextSiblingElement(Element elem)
Return the next sibling element of the given element.
for (Node n = elem.getNextSibling(); n != null; n = n.getNextSibling()) {
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        return (Element) n;
return null;
ElementgetNextSiblingElement(Element element)
get Next Sibling Element
try {
    Node node = element.getNextSibling();
    while (node != null && !(node instanceof Element)) {
        node = node.getNextSibling();
    return (Element) node;
} catch (IndexOutOfBoundsException e) {
    return null;
...
ElementgetNextSiblingElement(Element element)
get Next Sibling Element
Node sibling = element.getNextSibling();
while (sibling != null && sibling.getNodeType() != Node.ELEMENT_NODE)
    sibling = sibling.getNextSibling();
return (Element) sibling;