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>

[1225 byte] By [andrers2ba] at [2007-11-27 9:10:12]
# 1
Funny, there are tons of threads here that ask the same question as mine, but, after a long time looking, I found only one that has an answer that filled my needs: http://forum.java.sun.com/thread.jspa?forumID=34&threadID=612217Andre
andrers2ba at 2007-7-12 21:51:15 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...