[英]How do I serialize this list of names with xmlserializer?
以 XML 為例:
<Teaching StudyPoint="0" Description="xx" OtherDiscussionVideo="True" VideoAfterStudentItem="False">
<Theme>Test 1</Theme>
<SourceMaterial>Material 1</SourceMaterial>
<Names>
<Name Class="2">a</Name>
<Name Class="3">b</Name>
<Name Class="1">b</Name>
</Names>
</Teaching>
到目前為止,我已經成功創建了這個 class 用於序列化:
namespace OutlookCalIFConsole.MWBData
{
public class Teaching
{
[XmlAttribute]
public int StudyPoint
{
get => _StudyPoint; set => _StudyPoint = value;
}
private int _StudyPoint;
[XmlAttribute]
public string Description
{
get => _Description; set => _Description = value;
}
private string _Description;
[XmlAttribute]
public bool OtherDiscussionVideo
{
get => _OtherDiscussionVideo; set => _OtherDiscussionVideo = value;
}
private bool _OtherDiscussionVideo;
[XmlAttribute]
public bool VideoAfterStudentItem
{
get => _VideoAfterStudentItem; set => _VideoAfterStudentItem = value;
}
private bool _VideoAfterStudentItem;
public string Theme
{
get => _Theme; set => _Theme = value;
}
private string _Theme;
public string SourceMaterial
{
get => _SourceMaterial; set => _SourceMaterial = value;
}
private string _SourceMaterial;
public Teaching()
{
_OtherDiscussionVideo = false;
_VideoAfterStudentItem = false;
_StudyPoint = 0;
_Description = "";
_Theme = "";
_SourceMaterial = "";
}
}
}
如何序列化Name
值列表?
在Teaching
class 中嘗試以下操作:
public class Teaching {
[XmlArrayItem("Name")]
public Name[] Names;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.