List of utility methods to do XML Node Path
Vector | getVectorPathFromNode(Node node) get Vector Path From Node Vector path = new Vector(); while (node != null) { path.insertElementAt(node, 0); node = node.getParentNode(); return path; |
String | pathTo(Node xmlNode) path To StringBuilder result = new StringBuilder(); for (Node node = xmlNode; node != null; node = node.getParentNode()) { if (node.getNodeType() == Node.DOCUMENT_NODE) result.insert(0, node.getNodeName()); else result.insert(0, " -> " + node.getNodeName()); return result.toString(); ... |
String | pathUp(Node node, int level) calculates the path of the node up in the hierarchy, example of result is project/build/plugins/plugin level parameter designates the number of parents to climb eg. StringBuffer buf = new StringBuffer(); int current = level; while ((node != null) && (current > 0)) { if (node instanceof Element) { if (buf.length() > 0) { buf.insert(0, "/"); buf.insert(0, node.getNodeName()); ... |
String | pathUp(Node node, int level) path Up StringBuffer buf = new StringBuffer(); int current = level; while (node != null && current > 0) { if (node instanceof Element) { if (buf.length() > 0) { buf.insert(0, "/"); buf.insert(0, node.getNodeName()); ... |