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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…