How do I stop and empty tag in XML serializer?

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-06-02T13:31:33Z Indexed on 2010/06/02 13:34 UTC
Read the original article Hit count: 167

I have an object like this,

public class UserObj
{
    public string First {get; set;}
    public string Last  {get; set;}
    public addr Address {get; set;}

}

public class addr
{
    public street {get; set;}
    public town   {get; set;}
}

Now when I use XmlSerializer on it and street and town are empty I get this in the XML output,

 <Address />

Is there a way not to output this empty tag?

Thanks

© Stack Overflow or respective owner

Related posts about .NET

Related posts about xml-serialization