Java XML Node Path getCompletePathForANode(Node objNode)

Here you can find the source of getCompletePathForANode(Node objNode)

Description

get Complete Path For A Node

License

Open Source License

Declaration

public static String getCompletePathForANode(Node objNode) 

Method Source Code

//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;
    }
}

Related

  1. addElementPath(Node element, String path)
  2. createAndAppendNode(Node root, String path)
  3. extractNodes(Node node, String path)
  4. extractPath(Node node, String[] path)
  5. extractPaths(Node node, String[] path)
  6. getContent(Node n, String path)
  7. getDescendant(Node node, String path)
  8. getElementViaPath(Node node, String path)
  9. getFullPath(Node node)