Here you can find the source of getCompletePathForANode(Node objNode)
public static String getCompletePathForANode(Node objNode)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.Node; public class Main { public static String getCompletePathForANode(Node objNode) { String strCompletePathForNode = objNode.getNodeName(); Node tempNode = objNode;//from w w w. j a v a 2s.co m while (tempNode.getParentNode() != null) { tempNode = tempNode.getParentNode(); if (tempNode.getNodeName().equals("#document")) strCompletePathForNode = "/" + strCompletePathForNode; else strCompletePathForNode = tempNode.getNodeName() + "/" + strCompletePathForNode; } return strCompletePathForNode; } }