Here you can find the source of addElementAndSetContent(Document doc, String name, Element parent, String text)
public static Element addElementAndSetContent(Document doc, String name, Element parent, String text)
//package com.java2s; /* Copyright 2004 - 2007 Kasper Nielsen <kasper@codehaus.org> Licensed under * the Apache 2.0 License, see http://coconut.codehaus.org/license. *//* ww w . j a v a 2s.c o m*/ import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static Element addElementAndSetContent(Document doc, String name, Element parent, String text) { Element ee = addElement(doc, name, parent); ee.setTextContent(text); return ee; } public static Element addElement(Document doc, String name, Element parent) { Element ee = doc.createElement(name); parent.appendChild(ee); return ee; } }