public void ReadData(){//读取XML文件
string xmlFielPath = Application.dataPath + "/mybackpages/BackPages.xml";//文件路径
XmlDocument doc = new XmlDocument ();
doc.Load (xmlFielPath);
XmlNode root = doc.SelectSingleNode ("Pages");
foreach (XmlElement item in root) {
MyPage _m = new MyPage (); //对象,用于管理XML文件内容
_m.id = item.ChildNodes [0].InnerText;
_m.equName = item.ChildNodes [1].InnerText;
_m.howMuch = item.ChildNodes [2].InnerText;
_m.property = item.ChildNodes [3].InnerText;
_m.allInfo = item.ChildNodes [4].InnerText;
MyPageList.mp.Add (_m);//将对象添加到一个List中。
}
doc.Save (xmlFielPath);
}
<?xml version="1.0" encoding="UTF-8"?>
<Pages>
<page>
<ID>b</ID>
<equName>bluePotion01</equName>
<howMuch>99</howMuch>
<property>AddBlue 500/s,Total 5s</property>
<Allinfo>this is a magic bottle,it can support the mage release skills, and againt the</Allinfo>
</page>
<page>
<ID>b</ID>
<equName>bluePotion02</equName>
<howMuch>88</howMuch>
<property>AddBlue 1500/s,Total 5s</property>
<Allinfo>this is a magic bottle,it can support the mage release skills, and againt the</Allinfo>
</page>
<page>
<ID>c</ID>
<equName>cloth01</equName>
<howMuch>1</howMuch>
<property>Defense 150d</property>
<Allinfo>Protect your chest!</Allinfo>
</page>
<page>
<ID>c</ID>
<equName>cloth02</equName>
<howMuch>1</howMuch>
<property>Defense 350d</property>
<Allinfo>Protect your chest!</Allinfo>
</page>
<page>
<ID>h</ID>
<equName>hat01</equName>
<howMuch>1</howMuch>
<property>Defense 120d</property>
<Allinfo>Protect your head!</Allinfo>
</page>
<page>
<ID>h</ID>
<equName>hat02</equName>
<howMuch>1</howMuch>
<property>Defense 150d</property>
<Allinfo>Protect your head!</Allinfo>
</page>
<page>
<ID>t</ID>
<equName>trousers01</equName>
<howMuch>1</howMuch>
<property>Defense 100d</property>
<Allinfo>Protect your thighs!</Allinfo>
</page>
<page>
<ID>t</ID>
<equName>trousers02</equName>
<howMuch>1</howMuch>
<property>Defense 150d</property>
<Allinfo>Protect your thighs!</Allinfo>
</page>
<page>
<ID>w</ID>
<equName>weapon01</equName>
<howMuch>1</howMuch>
<property>Attack 250A</property>
<Allinfo>It can help you to kill another player in game!</Allinfo>
</page>
<page>
<ID>r</ID>
<equName>redPotion02</equName>
<howMuch>87</howMuch>
<property>trest 700/s,6s</property>
<Allinfo>Treat your life!</Allinfo>
</page>
</Pages>