Example usage for org.w3c.dom Node lookupPrefix

List of usage examples for org.w3c.dom Node lookupPrefix

Introduction

In this page you can find the example usage for org.w3c.dom Node lookupPrefix.

Prototype

public String lookupPrefix(String namespaceURI);

Source Link

Document

Look up the prefix associated to the given namespace URI, starting from this node.

Usage

From source file:Main.java

private static String getNodeNameWithNamespace(Node node) {
    String name = node.getNodeName();
    String ns = node.getNamespaceURI();
    String prefix = (ns != null) ? node.lookupPrefix(ns) : null;
    if ((prefix != null) && !name.startsWith(prefix + ":")) {
        name = prefix + ":" + name;
    }// www .j  a va 2s .c om
    return name;
}