title: How do you force explicit tag closing with Linq XML?
body: <p>This is the same question as:
  <a href="https://stackoverflow.com/questions/462747/explicit-element-closing-tags-with-system-xml-linq-namespace">Explicit Element Closing Tags with System.Xml.Linq Namespace</a></p>
  <p>but I use Net 4.0 and the answers do not work anymore.</p>
  <p>The problem is I save tags with no values really, and my output XML looks like this:</p>
  <p><code>&lt;field/&gt;</code></p>
  <p>But what I need is always opening and closing tag, i.e.</p>
  <p><code>&lt;field&gt;&lt;/field&gt;</code></p>
  <p><strong>QUESTION</strong>: how to do it?</p>
  <h1>Edits</h1>
  <h2>1</h2>
  <p>Adding empty nodes:</p>
  <pre><code>if (field_xml == null) // always true, because I create the file for the first time
  {
      field_xml = new XElement(XMLKeys.field,String.Empty);
      table_xml.Add(field_xml);
  }
  field_xml.SetAttributeValue(XMLKeys.name, field_info.Name);
  // ... setting some other attributes of this node
  </code></pre>
  <p>and later, saving the xml:</p>
  <pre><code>var writer = new FullEndingXmlTextWriter(parameters.OutputFilename, Encoding.UTF8);
  root_xml.Save(writer);
  </code></pre>
  <p>FullEndingXmlTextWriter is the specialized class which The Evil Greebo pointed out (it is supposed to force explicit closing tag).</p>