<channel>
<title>Best Web Gallery - Flash + CSS Gallery</title>
<link>http://bestwebgallery.com</link>
<description>Featuring the world best web design</description>
<pubDate>09 Dec 2009</pubDate>
<generator>http://wordpress.org/?v=2.3.2</generator>
<language>en</language>
</channel>
<channel>
<title>Best Web Gallery - Flash + CSS Gallery</title>
<link>http://bestwebgallery.com</link>
<description>Featuring the world best web design</description>
// pubDate missing
<generator>http://wordpress.org/?v=2.3.2</generator>
<language>en</language>
</channel>
XDocument rssFeed = XDocument.Load(url);
var feedResources = from details in rssFeed.Descendants("channel")
select new feedResource
{
Title = details.Element("title").Value,
Host = details.Element("link").Value,
Description = details.Element("description").Value,
PublishedOn = DateTime.Parse(details.Element("pubDate").Value),
Generator = details.Element("generator").Value,
Language = details.Element("language").Value
};
How can We check here before trying to get Element "pubDate " or others, because if not checked, throws null reference exception ??