XML配置文件:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<root>
<item ID="1">
<name>qwer</name>
<age>11</age>
</item>
<item ID="2">
<name>asdf</name>
<age>22</age>
</item>
<item ID="3">
<name>zxcv</name>
<age>33</age>
</item>
</root>
Public Class XmlCfg
{
public int Id;
public string Name;
public int Age;
}
使用字典储存数据
private readonly Dictionary<int, XmlCfg> _xmlCfgDictionary = new Dictionary<int, XmlCfg>();
//在C#文件IO接口加载文件
XmlDocument doc = new XmlDocument();
doc.Load(@"D:\Dev\info.xml");