Java examples for XML:XML Element Parent
get Pre Homo Sibling from XML Node
//package com.java2s; import org.w3c.dom.Node; public class Main { public static Node getPreHomoSibling(Node aNode) { Node preSibling = aNode;/*from w w w .j a va2s . c om*/ while ((preSibling = preSibling.getPreviousSibling()) != null) { //System.out.println("preSibling name: "+preSibling.getNodeName()+" "+preSibling.getTextContent()); if (preSibling.getNodeName().equals(aNode.getNodeName())) { return preSibling; } } return null; } }