0

In xml serialization I want to display self closing empty tag if a nullable type has null value. Below is my code for serialization.

 var sw = new StreamWriter(new FileStream(path, FileMode.Create),
            Encoding.UTF8);
            XmlSerializer ser =
            new XmlSerializer(typeof(Data));
            XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
            ns.Add("", "");
            ser.Serialize(sw, leadsOnlineUpload, ns);
            sw.Close();
2
  • 1
    It serializes the property as a self-closing tag with an attribute xsi:nil="true" which shows the value is null. Mar 15, 2016 at 23:41
  • but I also dont want to display xsi:nil="true" .
    – sqlcte
    Mar 16, 2016 at 3:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.