LINQ query problem

后端 未结 4 651
被撕碎了的回忆
被撕碎了的回忆 2021-01-27 01:31

Can\'t get any result in feeds. feedXML has the correct data.

XDocument feedXML = XDocument.Load(@\"http://search.twitter.com/search.atom?q=twitter\");

var feed         


        
4条回答
  •  独厮守ぢ
    2021-01-27 02:07

    You need to specify a namespace on both the Descendents and Element methods.

    XDocument feedXML = XDocument.Load(@"http://search.twitter.com/search.atom?q=twitter");
    
    XNamespace ns = "http://www.w3.org/2005/Atom";
    var feeds = from entry in feedXML.Descendants(ns + "entry")
                select new
                {
                PublicationDate = entry.Element(ns + "published").Value,
                Title = entry.Element(ns + "title").Value
                };
    

提交回复
热议问题