private IEnumerable <FeedItem> ParseAtom(string url) { try { XDocument document = XDocument.Load(url); if (document == null) { throw new ArgumentNullException(); } return(document.Root.Elements().Where(i => i.Name.LocalName == "entry").Select(item => new FeedItem { Description = item.Elements().First(i => i.Name.LocalName == "content").Value, Link = item.Elements().First(i => i.Name.LocalName == "link").Attribute("href").Value, PubDate = SafeDateParse.Parse(item.Elements().First(i => i.Name.LocalName == "published").Value), Title = item.Elements().First(i => i.Name.LocalName == "title").Value })); } catch (ArgumentNullException) { return(null);; } }
private IEnumerable <FeedItem> ParseRss(string url) { try { XDocument document = XDocument.Load(url); if (document == null) { throw new ArgumentNullException(); } return(document.Root.Descendants().First(i => i.Name.LocalName == "channel").Elements() .Where(i => i.Name.LocalName == "item").Select(item => new FeedItem { Description = item.Elements().First(i => i.Name.LocalName == "description").Value, Link = item.Elements().First(i => i.Name.LocalName == "link").Value, PubDate = SafeDateParse.Parse(item.Elements().First(i => i.Name.LocalName == "pubDate").Value), Title = item.Elements().First(i => i.Name.LocalName == "title").Value })); } catch (ArgumentNullException) { return(null); } }