Mega Code Archive

 
Categories / Java Tutorial / XML
 

Add Text object to an Element

import org.w3c.dom.Document; import org.w3c.dom.Element; public class Utils {   /**    * Add Text object to an Element.    * @param element the containing element    * @param text the text to add    */   public static void addText(Element element, String text) {     element.appendChild(element.getOwnerDocument().createTextNode(text));   } }