Here you can find the source of getNamespace(Element element)
public static QName getNamespace(Element element)
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; import javax.xml.namespace.QName; public class Main { public static QName getNamespace(Element element) { String uri = element.getNamespaceURI(); String prefix = element.getPrefix() == null ? "" : element.getPrefix(); if (uri == null) { return new QName(""); } else {// ww w .j av a 2 s.co m return new QName(uri, element.getLocalName(), prefix); } } }