可以将一个节点的内容进行XML反序列为一个对象
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
JobsManager manger = null;
using (System.Xml.XmlNodeReader sr = new System.Xml.XmlNodeReader(section))
{
XmlSerializer xz = new XmlSerializer(typeof(JobsManager));
manger = (ConnectManager)xz.Deserialize(sr);
}
return manger;
利用一些xml序列化的attribute类,可以将类与一个内容简洁美观的xml格式对应起来。
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
Code
using System;
using System.Xml.Serialization;
[XmlType("jobsSettings")]
public class JobsManager
{
Job[] jobsSettings;
[XmlElement("job")]
public Job[] JobsSettings
{
get { return jobsSettings; }
set { jobsSettings = value; }
}
}
详情请看《利用xml序列化简化程序配置文件中自定义配置节点的Create方法 》