get Pre XML Sibling - Android XML

Android examples for XML:XML Node

Description

get Pre XML Sibling

Demo Code


//package com.java2s;

import org.w3c.dom.Node;

public class Main {
    public static Node getPreHomoSibling(Node aNode) {
        Node preSibling = aNode;// w  w  w. j  a  v  a 2s  .c  o m
        while ((preSibling = preSibling.getPreviousSibling()) != null) {
            if (preSibling.getNodeName().equals(aNode.getNodeName())) {
                return preSibling;
            }
        }
        return null;
    }
}

Related Tutorials