Here you can find the source of addNamespace(Element element, QName qName)
public static void addNamespace(Element element, QName qName)
//package com.java2s; //License from project: Open Source License import org.w3c.dom.*; import javax.xml.namespace.QName; public class Main { public static void addNamespace(Element element, QName qName) { element.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:" + qName.getLocalPart(), qName.getNamespaceURI()); }/* w w w . j a v a 2 s . c o m*/ }