Java tutorial
//package com.java2s; /*--------------------------------------------------------------- * Copyright 2005 by the Radiological Society of North America * * This source software is released under the terms of the * RSNA Public License (http://mirc.rsna.org/rsnapubliclicense) *----------------------------------------------------------------*/ import org.w3c.dom.Node; public class Main { 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; } return name; } }