使用C#,我试图将XML序列化为这个字符串:
<root>
<IncludeRetElement>TxnID</IncludeRetElement>
<IncludeRetElement>TimeCreated</IncludeRetElement>
<IncludeRetElement>TimeModified</IncludeRetElement>
<IncludeRetElement>EditSequence</IncludeRetElement>
<IncludeRetElement>TxnNumber</IncludeRetElement>
<IncludeRetElement>CustomerRef</IncludeRetElement>
</root>
我的课程必须是什么样的?我不相信这会奏效:
public class Root
{
List<string> IncludeRetElement = new List<string>();
}
当我序列化时,是否需要向XMLSerializer对象添加特殊参数?
答案 0 :(得分:4)
这应该有效:
[XmlElement("IncludeRetElement")]
public string[] IncludeRetElement { get; set; }