XML Serialization: How to serialize a property with a null value without xsi:nill attribute?

I have a property the following code: [Serializable()] public class MyClass { [XmlElement(ElementName = "MyProperty")] public decimal? MyProperty { get; set; } } At the minute, when I serialize it I get: <MyProperty xsi:nil="true" /> But I want to get this: <MyProperty /> What is the best way of achieving this? I do not want to do any post-processing such as myXML.Replace("xsi:nil="true"", "")
2 Replies
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Deleted User 93w4ls0g
Yep this one Preferably I want to keep the property when it is null instead of omitting it
Want results from more Discord servers?
Add your server