Java XML Node Path getNodePath(Node node)

Here you can find the source of getNodePath(Node node)

Description

get Node Path

License

LGPL

Declaration

public static String[] getNodePath(Node node) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.Deque;
import java.util.LinkedList;
import org.w3c.dom.Node;

public class Main {
    public static String[] getNodePath(Node node) {
        Deque<String> list = new LinkedList<String>();
        list.addFirst(node.getNodeName());
        node = node.getParentNode();//  w w w .j  a v a 2s . co m
        while (node != null) {
            list.addFirst(node.getNodeName());
            node = node.getParentNode();
        }
        return list.toArray(new String[0]);
    }
}

Related

  1. getMatchingNodes(Node node, String[] nodePath, int cur, List res)
  2. getNode(Node node, String... nodePath)
  3. getNode(Node root, String nodePath)
  4. getNodeCompletePath(Node node)
  5. getNodePath(Node node)
  6. getNodePath(Node node)
  7. getNodePath(Node node, String postfix)
  8. getNodes(Node node, String path)
  9. getNodesPathName(Node node)