Example #1
0
        public static List <PowerSource> LoadPowerSources(string xmlfile)
        {
            List <PowerSource> powerSources = new List <PowerSource>();
            XPathDocument      doc          = new XPathDocument(xmlfile);
            XPathNavigator     nav          = doc.CreateNavigator();

            foreach (XPathNavigator n in nav.Select("/battle/powersources/powersource"))
            {
                PowerSource p     = new PowerSource();
                string      name  = n.GetAttribute("name", "");
                string      descr = n.GetAttribute("description", "");
                p.Name        = name;
                p.Description = descr;
                foreach (XPathNavigator n2 in n.Select("provides"))
                {
                    p.Provide(n2.GetAttribute("value", ""));
                }
                foreach (XPathNavigator n3 in n.Select("requires"))
                {
                    p.Require(n3.GetAttribute("value", ""));
                }
                powerSources.Add(p);
            }
            return(powerSources);
        }