xsd.exe show null property when serializing without displaying nil attribute

217 views Asked by At

I used xsd.exe to generate a cs file from my xsd file. I have an element that can have a null value. When I serialize the class the property disappears if it's null, if I set IsNullable = true, it shows the property but with nil attibutes, is there a way modify the cs file generated by xsd.exe to show the empty tag without attributes?

[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable = true)]
public string Phone {
    get { return this.phoneField; }
    set { this.phoneField = value; }
}

if Phone = null and IsNullable = true, I get

<Phone p7:nil="true" xmlns:p7="some namespace" />

if Phone = null and IsNullable = false, Phone doesn't even show up on my xml file.

Desired output

<Phone />
0

There are 0 answers