【发布时间】:2011-10-06 07:08:47
【问题描述】:
我正在尝试解析以下 xml,但没有成功任何人指导我我在这里犯了什么错误
string feedURL = "http://www.bbc.co.uk/arabic/index.xml";
XDocument feedSource;
feedSource = XDocument.Load(feedURL);
var another = (from myFeed in feedSource.Descendants("entry")
select new
{
feedTitle = myFeed.Element("title").Value,
//feedDescription = myFeed.Element("description").Value,
//feedLink = myFeed.Element("link").Value,
feedpubDate = myFeed.Element("published") != null ? myFeed.Element("published").Value : null
//feedcategory = myFeed.Element("category") != null ? myFeed.Element("category").Value : null,
//feedItems = myFeed.Descendants("entry")
}
);
if (another != null && another.Count() > 0)
{
}
else
{
Response.Write("No Record Found");
}
它显示没有找到记录。
任何帮助将不胜感激。
【问题讨论】:
-
我对此不太确定(并且无法在这台电脑上测试),但请尝试
from myFeed in feedSource.Element("feed").Elements("entry")。
标签: asp.net xml linq-to-xml