title: C# serialize simple object to xml. no namespace no Nulls
body: <p><strong>I got the following code:</strong></p>
  
  <pre><code>public class Alarm:IDisposable
  {
      MemoryStream _tmp;
      readonly XmlDocument _doc;
      private readonly XmlSerializerNamespaces _ns;
      private readonly XmlSerializer _x = new  XmlSerializer(typeof(Alarm));
      public int? ID { get; set; }
      public string SourceSystem { get; set; }
      public string SensorName { get; set; }
      public string ModelName { get; set; }
      public int? Severity { get; set; }
      public int? Duration { get; set; }
      public bool? Status { get; set; }
      public DateTime? StartTime { get; set; }
      public DateTime? EndTime { get; set; }
  
      public Alarm()
      {
          _tmp = new MemoryStream();
          _doc = new XmlDocument();
          _ns = new XmlSerializerNamespaces();
          _ns.Add("", "");
      }
      public string OuterXml()
      {
  
          //Add an empty namespace and empty value
          _x.Serialize(_tmp, this, _ns);
          _tmp.Position = 0;
          _doc.Load(_tmp);
          return _doc.OuterXml;
      }
  
  
      public void Dispose()
      {
          if (_tmp!=null)
          {
              _tmp.Close();
              _tmp = null;
          }
  
      }
  }
  </code></pre>
  
  <p><strong>I get as output</strong>"</p>
  
  <pre><code> &lt;?xml version=\"1.0\"?&gt;
   &lt;Alarm&gt;&lt;ID&gt;1&lt;/ID&gt;&lt;SourceSystem&gt;HMer&lt;/SourceSystem&gt;
   &lt;SensorName&gt;4&lt;/SensorName&gt;&lt;Severity d2p1:nil=\"true\" xmlns:d2p1=\"http://www.w3.org/2001/XMLSchema-instance\" /&gt;
   &lt;Duration&gt;500&lt;/Duration&gt;&lt;Status&gt;true&lt;/Status&gt;
   &lt;StartTime&gt;2011-07-19T12:29:51.171875+03:00&lt;/StartTime&gt;
  &lt;EndTime d2p1:nil=\"true\" 
   xmlns:d2p1=\"http://www.w3.org/2001/XMLSchema-instance\" /&gt;&lt;/Alarm&gt;
  </code></pre>
  
  <p><strong>I wanna get:</strong></p>
  
  <pre><code>&lt;Alarm&gt;&lt;ID&gt;1&lt;/ID&gt;&lt;SourceSystem&gt;HMer&lt;/SourceSystem&gt;&lt;SensorName&gt;4&lt;/SensorName&gt;
  &lt;Duration&gt;500&lt;/Duration&gt;&lt;Status&gt;true&lt;/Status&gt;
  &lt;StartTime&gt;2011-07-19T12:29:51.171875+03:00&lt;/StartTime&gt;&lt;/Alarm&gt;
  </code></pre>
  
  <p><strong>meaning no xmlns stuff, no tag where value is null.</strong></p>
  
  <p>please assist meh</p>