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 Element addTextNode(Document xmlDoc, Element ndParent, String nodeName, String nodeValue) { Element ndNode = xmlDoc.createElement(nodeName); Text ndTextNode = xmlDoc.createTextNode(nodeName); ndTextNode.setData(nodeValue); ndNode.appendChild(ndTextNode); ndParent.appendChild(ndNode); return ndNode; } }