Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Text; public class Main { public static void encodeString(Document doc, Element parent, String str, String namespaceURI, String qualifiedName) { if (str != null) { Element elm = doc.createElementNS(namespaceURI, qualifiedName); Text strVal = doc.createTextNode(str); elm.appendChild(strVal); parent.appendChild(elm); } } }