LINQ query problem

后端 未结 4 649
被撕碎了的回忆
被撕碎了的回忆 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:02

    You need to specify the namespace:

    // This is the default namespace within the feed, as specified
    // xmlns="..." 
    XNamespace ns = "http://www.w3.org/2005/Atom";
    
    var feeds = from entry in feedXML.Descendants(ns + "entry")
                ...
    

    Namespace handling is beautifully easy in LINQ to XML compared with everything other XML API I've ever used :)

提交回复
热议问题