使用diggapi将XML转换为LINQ

使用diggapi将XML转换为LINQ,xml,linq,api,digg,Xml,Linq,Api,Digg,继续我前面的问题(http://stackoverflow.com/questions/7817619/unknown-error-using-digg-api-and-uri-handler-silverlight,我想感谢你的回答)我现在有一个后续的问题 为了从中提取数据,我们得到了以下XML到LINQ的代码 var stories = from story in document.Descendants("story") //where stor

继续我前面的问题(http://stackoverflow.com/questions/7817619/unknown-error-using-digg-api-and-uri-handler-silverlight,我想感谢你的回答)我现在有一个后续的问题

为了从中提取数据,我们得到了以下XML到LINQ的代码

    var stories = from story in document.Descendants("story")
                  //where story.Element("thumbnail") != null
                  select new DiggStory
                  {
                      Id = (string)story.Attribute("story_id"),
                      Title = (string)story.Element("title"),
                      Description = (string)story.Element("description"),
                      ThumbNail = (string)story.Element("thumbnail").Attribute("src"),
                      //HrefLink = (string)story.Attribute("permalink"),
                      NumDiggs = (int)story.Attribute("diggs")
                  };
这是预期的工作方式,但鉴于DiggAPI已经过时,我更愿意成为新的API,它可以创建新的API

现在我想知道如何调整XML到LINQ代码以利用这个新的XML文件? 我知道问题出在你身上

   var stories = from story in document.Descendants("story")
但是我不知道我需要把它改成什么,因为它有更多的级别。我在想一些类似的事情

var stories = from item in document.Descendants("stories")
但这似乎不起作用

我想再次感谢你帮助我解决这个问题和任何进一步的问题,这真是一个伟大的网站

谢谢你,托马斯从这个开始:

var stories = from item in document.RootElement.Element("stories").Descendants("item")
              select new DiggStory
              {
                  Id = item.Element("story_id").Value
                  // ...etc
              }
您可以使用了解有关解析XML文档的更多信息。对您特别有用的可能是,它显示了为XML文档中的每个“元素”(标记)定义的所有方法和属性