when I serialize a c# object with a nullable DateTime in it, is there a way to leave the null value out of the xml file instead of having
<EndDate d2p1:nil="true" xmlns:d2p1="http://www.w3.org/2001/XMLSchema-instance" />
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can use the
Specifiedextended property to leave out null values (or any other value, for that matter). Basically, create another property with the same name as the serialized property with the wordSpecifiedadded to the end as a boolean. If theSpecifiedproperty istrue, then the property it is controlling is serialized. Otherwise, if it isfalse, the other property is left out of the xml file completely: