Utils.java Source code

Java tutorial

Introduction

Here is the source code for Utils.java

Source

import javax.xml.XMLConstants;

import org.w3c.dom.Element;

public class Utils {

    /**
     * Add a namespace prefix definition to an element.
     * 
     * @param element
     * @param namespaceUri
     * @param prefix
     */
    public static void addNamespacePrefix(Element element, String namespaceUri, String prefix) {
        element.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + prefix, namespaceUri);
    }

}