I have an object that I serialize to XML. If one of the properties in the object is null, then native serialization ignores to add this as the attribute. Is this normal behavior, if so, is there a way I can override it?
ex:
public class Test
{
[XmlAttribute]
public string value {set; get; }
[XmlAttribute]
public string key {set; get; }
}
When value is null, i get
<Root>
<Test key="blah">
</Root>
See Question&Answers more detail:os