Ejemplo n.º 1
0
        public void Delete(string path, Location location)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(path +  "tp.xml");

            XmlNode lo = doc.SelectSingleNode("/body/Location[@name='" + location.GetName() + "']");
            lo.ParentNode.RemoveChild(lo);

            doc.Save(path + "tp.xml");
        }
Ejemplo n.º 2
0
        public List<Location> Read(string path)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(path + "tp.xml");

            XmlNodeList aNodes = doc.SelectNodes("/body/Location");
            List<Location> locations = new List<Location>();
            foreach(XmlNode aNode in aNodes)
            {
                XmlAttribute nameAttribute = aNode.Attributes["name"];
                XmlAttribute xAttribute = aNode.Attributes["x"];
                XmlAttribute yAttribute = aNode.Attributes["y"];
                XmlAttribute zAttribute = aNode.Attributes["z"];

                string name = nameAttribute.Value;
                float x = float.Parse(xAttribute.Value);
                float y = float.Parse(yAttribute.Value);
                float z = float.Parse(zAttribute.Value);
                Location loc = new Location(x,y,z,name);
                locations.Add(loc);
            }

            return locations;
        }