Linq to xml demo

前端之家收集整理的这篇文章主要介绍了Linq to xml demo前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
var books = new[] {
              new {Title="Ajax in Action",Publisher="Manning",Year=2005 },new {Title="Windows Forms in Action",Year=2006 },new {Title="RSS and Atom in Action",Year=2006 }
        };

        // Build the XML fragment based on the collection
        XElement xml = new XElement("books",from book in books
          where book.Year == 2006
          select new XElement("book",new XAttribute("title",book.Title),new XElement("publisher",book.Publisher)
          )
        );

        // Dump the XML to the console
        Console.WriteLine(xml);
        Console.ReadKey();
原文链接:https://www.f2er.com/xml/300069.html

猜你在找的XML相关文章