Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool SaveXML(string filename)
- {
- XmlDocument document = new XmlDocument();
- XmlDeclaration declaration = document.CreateXmlDeclaration("1.0", null, null);
- declaration.Encoding = "utf-8";
- document.AppendChild(declaration);
- XmlElement root = document.CreateElement("", "Bank", "");
- root.SetAttribute("version", "1");
- document.AppendChild(root);
- // Add different race sections
- XmlElement protoss = document.CreateElement("", "Section", "");
- protoss.SetAttribute("name", "ProtossBuildOrders");
- XmlElement zerg = document.CreateElement("", "Section", "");
- zerg.SetAttribute("name", "ZergBuildOrders");
- XmlElement terran = document.CreateElement("", "Section", "");
- terran.SetAttribute("name", "TerranBuildOrders");
- root.AppendChild(protoss);
- root.AppendChild(zerg);
- root.AppendChild(terran);
- foreach (BuildOrder build in buildOrders)
- {
- XmlElement key = document.CreateElement("Key");
- key.SetAttribute("name", build.Key);
- XmlElement value = document.CreateElement("Value");
- value.SetAttribute("string", build.Value);
- key.AppendChild(value);
- switch (build.Race)
- {
- case (BuildRace.Protoss):
- protoss.AppendChild(key);
- break;
- case (BuildRace.Zerg):
- zerg.AppendChild(key);
- break;
- case (BuildRace.Terran):
- terran.AppendChild(key);
- break;
- }
- }
- document.Save(filename);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement