XML读取:
string Path = Application.dataPath + "/Resources/Bag.xml";
XmlDocument doc = new XmlDocument();
doc.Load(Path);
XmlNode root = doc.SelectSingleNode("Items");
XmlNodeList nodelist = root.ChildNodes;
foreach(XmlNode node in nodelist)
{
XmlNodeList nnode = node.ChildNodes;
item_information item = new item_information();
item.ID = int.Parse(nnode[0].InnerText);
item.Name = nnode[1].InnerText;
item.Icon = nnode[2].InnerText;
item.Count = int.Parse(nnode[3].InnerText);
BagID.Add(item.ID);
bagDic.Add(item.ID, item);
}
XML添加节点: