Here you can find the source of setTextContent(Element elem, String content)
public static void setTextContent(Element elem, String content)
//package com.java2s; //License from project: Apache License import org.w3c.dom.*; public class Main { public static void setTextContent(Element elem, String content) { Document doc = elem.getOwnerDocument(); if ((content != null) && !content.equals("")) { Text textNode = doc.createTextNode(content); elem.appendChild(textNode);/*from ww w. j a v a2s.co m*/ } } }