Java examples for XML:DOM Node Value
Get XML Node level away from root
//package com.java2s; import org.w3c.dom.Node; public class Main { /**// ww w . j a v a 2 s . co m * in this NQF project, the root node is QualityMeasureDocument * @param aNode * @param rootNode * @return the distance a node to the rootnode */ public static int getHeight(Node aNode, Node rootNode) { int height = 0; if (aNode == null) { return 0; } while (aNode.getParentNode() != rootNode) { aNode = aNode.getParentNode(); height++; } return height; } }