LINQ查询问题 [英] LINQ query problem
本文介绍了LINQ查询问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无法在Feed中获得任何结果. feedXML包含正确的数据.
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 feeds = from entry in feedXML.Descendants("entry")
select new
{
PublicationDate = entry.Element("published").Value,
Title = entry.Element("title").Value
};
我想念什么?
推荐答案
您需要在Descendents和Element方法上都指定一个名称空间.
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
};
这篇关于LINQ查询问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文