Java tutorial
//package com.java2s; import org.w3c.dom.Document; import org.w3c.dom.Element; public class Main { public static void createOptionalChildText(Document paramDocument, Element paramElement, String paramString1, String paramString2) { if ((paramString2 == null) || (paramString2.length() == 0)) return; Element localElement = paramDocument.createElement(paramString1); localElement.appendChild(paramDocument.createTextNode(paramString2)); paramElement.appendChild(localElement); } }