Java XML Node Sibiling getSibling(Node current)

Here you can find the source of getSibling(Node current)

Description

Get the sibling in next context

License

Open Source License

Parameter

Parameter Description
current a parameter

Return

the sibling

Declaration

public static Node getSibling(Node current) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import org.w3c.dom.Node;

public class Main {
    /**//from  w  w  w.  j a  v a  2  s. co m
     * Get the sibling in next context
     * 
     * @param current
     * @return the sibling
     */
    public static Node getSibling(Node current) {
        Node sibling = current.getNextSibling();
        Node tmpParent = current;
        while (tmpParent != null && sibling == null) {
            tmpParent = tmpParent.getParentNode();
            if (tmpParent != null) {
                sibling = tmpParent.getNextSibling();
            }
        }
        return sibling;
    }
}

Related

  1. getPreHomoSibling(Node aNode)
  2. getPreviousSibling(Node node, short nodeType)
  3. getPreviousSiblingByName(Node currentNode, String tagName)
  4. getPreviousSiblingElement(Node node)
  5. getPreviousSiblingElement(Node node)
  6. getSiblingValues(Node currentNode, Set siblingTags)