Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static Element createTextElement(Document dom, String tagName, String content) { Element root = dom.createElement(tagName); if (content != null) root.appendChild(dom.createTextNode(content)); return root; } }