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

booleancontainsSiblings(org.w3c.dom.Node node)
contains Siblings
NodeList childNodes = node.getChildNodes();
if (childNodes != null)
    if (childNodes.getLength() > 1)
        return true;
    else if (containsSiblings(childNodes.item(0)))
        return true;
return false;
ElementgetFirstElementSibling(Node node)
Returns the first subsequent sibling of a given node which is an Element.
return (node == null || node instanceof Element) ? (Element) node
        : getFirstElementSibling(node.getNextSibling());
ElementgetFirstSiblingElmt(Node aNode)
get First Sibling Elmt
if (aNode == null) {
    return null;
Node wNode = aNode.getNextSibling();
while (wNode != null && wNode.getNodeType() != Node.ELEMENT_NODE) {
    wNode = wNode.getNextSibling();
return (Element) wNode;
...
NodegetFirstSiblingNamed(Node node, String name)
Returns the first sibling of node, or node itself, which has the given name.
while (node != null && !node.getNodeName().equals(name)) {
    node = node.getNextSibling();
return node;
intgetLocHomoSibling(Node aNode)
aims at finding the location of the current node of its kind.
int countOfBranch = 0;
Node preSibling = aNode;
while ((preSibling = preSibling.getPreviousSibling()) != null) {
    if (preSibling.getNodeName().equals(aNode.getNodeName())) {
        countOfBranch++;
return countOfBranch;
...
ElementgetNextElementSibling(Node node)
Returns the next sibling element of the given node.
node = node.getNextSibling();
while (node != null) {
    if (node.getNodeType() == Node.ELEMENT_NODE) {
        return (Element) node;
    node = node.getNextSibling();
return null;
...
NodegetNextElementSibling(Node node)
get Next Element Sibling
node = node.getNextSibling();
while (node != null && node.getNodeType() != Node.ELEMENT_NODE) {
    node = node.getNextSibling();
return node;
NodegetNextElementSibling(Node node)
get Next Element Sibling
node = node.getNextSibling();
while (node != null && node.getNodeType() != Node.ELEMENT_NODE) {
    node = node.getNextSibling();
return node;
NodegetNextHomoSibling(Node aNode)
this function is different from above one.
Node nextSibling = aNode;
while ((nextSibling = nextSibling.getNextSibling()) != null) {
    if (nextSibling.getNodeName().equals(aNode.getNodeName())) {
        return nextSibling;
return null;
NodegetNextNamedSibling(Node node, String nodeName)
get Next Named Sibling
Node nextSibling = node.getNextSibling();
while (nextSibling != null && !nextSibling.getNodeName().equals(nodeName)) {
    nextSibling = nextSibling.getNextSibling();
return nextSibling;