var posts = from item in xRss.Descendants("item")
select new
{
Title = item.Element("title").Value,
Date = item.Element("pubDate").Value,
Url = item.Element("link").Value
};
if "Title" does not exist, it would throw exception. There is a easy solution for it:
var posts = from item in xRss.Descendants("item")
select new
{
Title = item.Element("title").Value,
Date = item.Element("pubDate") == null ? string.Empty : item.Element("pubDate").Value,
Url = item.Element("link").Value
};
No comments:
Post a Comment