Exemple #1
0
        public void OutputXml(XDocument document)
        {
            foreach (XElement ElementTeam in document.Element("teams").Elements("team"))
            {
                XAttribute TeamAttributeOutput = ElementTeam.Attribute("team");
                foreach (XElement AllElements in document.Element("teams").Element("team").Elements("player"))
                {
                    XAttribute PlayerAttributeOutput = AllElements.Attribute("name");
                    XElement   WeightElementOutput1  = AllElements.Element("weight");
                    XElement   WeightElementOutput2  = AllElements.Element("height");
                    XElement   WeightElementOutput3  = AllElements.Element("wage");

                    if (TeamAttributeOutput != null && WeightElementOutput1 != null && WeightElementOutput2 != null && WeightElementOutput3 != null)
                    {
                        Console.WriteLine(new string('-', 100));
                        Console.WriteLine("Команда: {0}", TeamAttributeOutput.Value);
                        Console.WriteLine("Имя игрока: {0}", PlayerAttributeOutput.Value);
                        Console.WriteLine("Вес: {0}", WeightElementOutput1.Value);
                        Console.WriteLine("Рост: {0}", WeightElementOutput2.Value);
                        Console.WriteLine("Зароботная плата: {0}", WeightElementOutput3.Value);
                        Console.WriteLine();
                    }
                }
                Console.WriteLine();
            }
        }
Exemple #2
0
 public void UpdateXml(XDocument document, string temp)
 {
     foreach (XElement AllElements in document.Element("teams").Element("team").Elements("player"))
     {
         if (AllElements.Attribute("name").Value == temp)
         {
             Console.WriteLine("Новое имя игрока: ");
             temp = Console.ReadLine();
             AllElements.Attribute("name").Value = temp;
         }
         else if (AllElements.Element("weight").Value == temp)
         {
             Console.WriteLine("Новый вес игрока: ");
             temp = Console.ReadLine();
             AllElements.Element("weight").Value = temp;
         }
         else if (AllElements.Element("height").Value == temp)
         {
             Console.WriteLine("Новый рост игрока: ");
             temp = Console.ReadLine();
             AllElements.Element("height").Value = temp;
         }
         else if (AllElements.Element("wage").Value == temp)
         {
             Console.WriteLine("Новая зароботная плата игрока: ");
             temp = Console.ReadLine();
             AllElements.Element("wage").Value = temp;
         }
     }
     document.Save("teams.xml");
 }
Exemple #3
0
 public void DeleteXml(XDocument document, string temp1)
 {
     foreach (XElement AllElements in document.Element("teams").Element("team").Elements("player"))
     {
         if (AllElements.Attribute("name").Value == temp1)
         {
             AllElements.Remove();
         }
         else if (AllElements.Element("weight").Value == temp1)
         {
             AllElements.Remove();
         }
         else if (AllElements.Element("height").Value == temp1)
         {
             AllElements.Remove();
         }
         else if (AllElements.Element("wage").Value == temp1)
         {
             AllElements.Remove();
         }
     }
     document.Save("teams.xml");
 }