serialize empty element

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeremy Chapman

    #1

    serialize empty element

    I've created a class, but when I serialize it I want the empty properties to
    generate elements who's properties haven't been set.

    What's happening:
    <Identity>
    <BirthDate>0000 1-01-01T00:00:00.000 00000-08:00</BirthDate>
    </Identity>

    What i want:
    <Identity>
    <BirthDate>0000 1-01-01T00:00:00.000 00000-08:00</BirthDate>
    <Gender/>
    </Identity>

    This is my class:

    [Serializable]
    [System.Xml.Seri alization.XmlTy peAttribute(Nam espace="http://test")]
    [System.Xml.Seri alization.XmlRo otAttribute(Nam espace="http://test",
    IsNullable=fals e)]
    public class Identity
    {
    /// <remarks/>
    [System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)] public System.DateTime BirthDate; /// <remarks/[System.Xml.Seri alization.XmlEl ementAttribute( Form=System.Xml .Schema.XmlSche maForm.Unqualif ied)] public string Gender;}

Working...