Take this sample 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>
So far, I have managed to create this class for serialization:
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 = "";
}
}
}
How do I serialize the list of Name
values?
Try following inside Teaching
class:
public class Teaching {
[XmlArrayItem("Name")]
public Name[] Names;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.