Exemplo n.º 1
0
        private static FeedItem GetItemFromFeedEntry(XPathNodeIterator xPathNodeIterator)
        {
            var item = new FeedItem();

            if (xPathNodeIterator.Current != null)
            {
                var pathNavigator = xPathNodeIterator.Current.CreateNavigator();

                var titlenode = pathNavigator.SelectSingleNode("title");
                item.Title = titlenode == null ? "(untitled)" : WebUtility.HtmlDecode(titlenode.ToString()).Trim();

                var linknode = pathNavigator.SelectSingleNode("link");
                if (linknode != null)
                {
                    Uri result;
                    if (Uri.TryCreate(linknode.ToString(), UriKind.Absolute, out result))
                    {
                        item.Link = result;
                    }
                }

                try
                {
                    var tempnav = pathNavigator.SelectSingleNode("pubDate");
                    if (tempnav != null)
                    {
                        DateTime gdt;
                        var      res = DateTime.TryParse(tempnav.ToString(), out gdt);
                        if (res)
                        {
                            item.Date = gdt;
                        }
                    }
                }
                catch (FormatException)
                {
                }
            }
            return(item);
        }