LINQ to XML 简单的小例子

 linq to XML

 XDocument xml = XDocument.Load("http://rss.sina.com.cn/news/marquee/ddt.xml");

        var news = from x in xml.Descendants("item")

                   select new

                   {

                       name = x.Element("title").ToString(),

                       url = x.Element("link").ToString()



                   };

        foreach (var e in news)

        {

            lbl001.Text += e.name + " - " + e.url + "<br/>";

        }



 

你可能感兴趣的:(LINQ)