title: Create empty text node in DOM Document
body: <p>How can we create an empty node in a DOM document without getting <code>java.lang.NullPointerException</code> while writing XML files with <code>Transformer</code>?</p>
  
  <p>I am writing an XML Document with some nodes possibly with empty values using <code>element.appendChild(documnet.createTextNode(nodeValue));</code></p>
  
  <p>Here this nodeValue could be an empty String or lets say null or empty value, then how could we force it to write this empty text node like <code>&lt;emptyTextNode/&gt; or &lt;emptyTextNode&gt;&lt;emptyTextNode&gt;</code></p>
  
  <p>If I just simply write this node with an empty value, <code>Transformer</code> throws <code>NullPointerException</code>, while transforming the Document to XML.</p>
  
  <p>This nullpointer exception needs to be avoided and allow this empty node in output XML anyhow condition.</p>