Csharp/CSharp Tutorial/XML LINQ/XAttribute

Материал из .Net Framework эксперт
Версия от 15:16, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Linq To Xml Constructors

<source lang="csharp">using System; using System.Collections.Generic; using System.Linq; using System.Xml.Linq; using System.Text;

   class Program
   {
       static void Main(string[] args)
       {
           XDocument xdoc = new XDocument(
               new XElement("customers",
                   new XElement("customer",
                       new XAttribute("ID", "A"),
                       new XAttribute("City", "B"),
                       new XAttribute("Region", "C"),
                       new XElement("order",
                           new XAttribute("Item", "Widget"),
                           new XAttribute("Price", 100)
                     ),
                     new XElement("order",
                       new XAttribute("Item", "Tire"),
                       new XAttribute("Price", 200)
                     )
                   )
               )
           );
           Console.WriteLine(xdoc);
       }
   }</source>