Xml Serialization - Render Empty Element

前端 未结 5 1449
说谎
说谎 2021-02-07 03:44

I am using the XmlSerializer and have the following property in a class

public string Data { get; set; }

which I need to be output exactly like

5条回答
  •  清歌不尽
    2021-02-07 04:39

    You could try adding the XMLElementAttribute like [XmlElement(IsNullable=true)] to that member. That will force the XML Serializer to add the element even if it is null.

提交回复
热议问题