title: What is the correct way to represent null XML elements?
body: <p>I have seen <code>null</code> elements represented in several ways:</p>
  
  <p><strong>The element is present with <code>xsi:nil="true"</code>:</strong></p>
  
  <pre><code> &lt;book&gt;
       &lt;title&gt;Beowulf&lt;/title&gt;
       &lt;author xsi:nil="true"/&gt;
   &lt;/book&gt;
  </code></pre>
  
  <p><strong>The element is present, but represented as an empty element</strong> (which I believe is wrong since 'empty' and <code>null</code> are semantically different):</p>
  
  <pre><code> &lt;book&gt;
       &lt;title&gt;Beowulf&lt;/title&gt;
       &lt;author/&gt;
   &lt;/book&gt;
  
   &lt;!-- or: --&gt;
   &lt;book&gt;
       &lt;title&gt;Beowulf&lt;/title&gt;
       &lt;author&gt;&lt;/author&gt;
   &lt;/book&gt;
  </code></pre>
  
  <p><strong>The element is not present at all in the returned markup</strong>:</p>
  
  <pre><code> &lt;book&gt;
       &lt;title&gt;Beowulf&lt;/title&gt;
   &lt;/book&gt;
  </code></pre>
  
  <p><strong>The element has a <code>&lt;null/&gt;</code> child element</strong> (from <a href="https://stackoverflow.com/questions/774192/what-is-the-correct-way-to-represent-null-xml-elements/774229#774229">TStamper</a> below):</p>
  
  <pre><code> &lt;book&gt;
       &lt;title&gt;Beowulf&lt;/title&gt;
       &lt;author&gt;&lt;null/&gt;&lt;/author&gt;
   &lt;/book&gt;
  </code></pre>
  
  <p>Is there a correct, or canonical way to represent such a <code>null</code> value? Are there additional ways than the above examples?</p>
  
  <p>The XML for the examples above is contrived, so don't read too far into it. :)</p>