Getting XPath from current Node
Hey everyone,
I have a JDom document and I'm trying to visit all the nodes and print their path. How do I do the printing?
This is what I have (from javaalmanac):
// This method visits all the nodes in a DOM tree
publicstaticvoid visit(Node node,int level){
// Process node
// If there are any children, visit each one
NodeList list = node.getChildNodes();
for (int i=0; i<list.getLength(); i++){
// Get child node
Node childNode = list.item(i);
//How do I print childNode's xpath?
// "/root/level1/level2/..." ?
// Visit child node
visit(childNode, level+1);
}
}
Thanks,
Andre>

