I got the following 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;
        }
    }
}
I get as output"
 <?xml version=\"1.0\"?>
 <Alarm><ID>1</ID><SourceSystem>HMer</SourceSystem>
 <SensorName>4</SensorName><Severity d2p1:nil=\"true\" xmlns:d2p1=\"http://www.w3.org/2001/XMLSchema-instance\" />
 <Duration>500</Duration><Status>true</Status>
 <StartTime>2011-07-19T12:29:51.171875+03:00</StartTime>
<EndTime d2p1:nil=\"true\" 
 xmlns:d2p1=\"http://www.w3.org/2001/XMLSchema-instance\" /></Alarm>
I wanna get:
<Alarm><ID>1</ID><SourceSystem>HMer</SourceSystem><SensorName>4</SensorName>
<Duration>500</Duration><Status>true</Status>
<StartTime>2011-07-19T12:29:51.171875+03:00</StartTime></Alarm>
meaning no xmlns stuff, no tag where value is null.
please assist meh
 
     
     
    