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 writeStringElement(Document document, Element parentElement, String elementTagName, String elementValue) { Element stringElement = createChildElement(document, parentElement, elementTagName); Text textNode = document.createTextNode(elementValue); stringElement.appendChild(textNode); } private static Element createChildElement(Document document, Element parentElement, String elementTagName) { Element stringElement = document.createElement(elementTagName); parentElement.appendChild(stringElement); return stringElement; } }