private static RssSchema GetRssSchema(XElement item)
        {
            RssSchema rssItem = new RssSchema
            {
                Author      = GetItemAuthor(item),
                Title       = Utility.DecodeHtml(item.GetSafeElementString("title").Trim()),
                Summary     = RssHelper.SanitizeString(Utility.DecodeHtml(GetItemSummary(item)).Trim().Truncate(500, true)),
                Content     = GetItemSummary(item),
                ImageUrl    = GetItemImage(item),
                PublishDate = item.GetSafeElementDate("published"),
                FeedUrl     = item.GetLink("alternate"),
            };

            string id = item.GetSafeElementString("guid").Trim();

            if (string.IsNullOrEmpty(id))
            {
                id = item.GetSafeElementString("id").Trim();
                if (string.IsNullOrEmpty(id))
                {
                    id = rssItem.FeedUrl;
                }
            }
            rssItem._id = id;
            return(rssItem);
        }
Exemplo n.º 2
0
        /// <summary>
        /// RSS all versions
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private static RssSchema ParseItem(XElement item)
        {
            var rssItem = new RssSchema();

            rssItem.Title   = Utility.DecodeHtml(item.GetSafeElementString("title").Trim());
            rssItem.FeedUrl = item.GetSafeElementString("link");

            rssItem.Author = GetItemAuthor(item);

            string description = item.GetSafeElementString("encoded", NsRdfContentNamespaceUri);

            if (string.IsNullOrEmpty(description))
            {
                description = item.GetSafeElementString("description");
                if (string.IsNullOrEmpty(description))
                {
                    description = item.GetSafeElementString("content");
                }
            }

            rssItem.Summary = RssHelper.SanitizeString(Utility.DecodeHtml(description).Trim().Truncate(500, true));
            rssItem.Content = RssHelper.SanitizeString(description);

            string id = item.GetSafeElementString("guid").Trim();

            if (string.IsNullOrEmpty(id))
            {
                id = item.GetSafeElementString("id").Trim();
                if (string.IsNullOrEmpty(id))
                {
                    id = rssItem.FeedUrl;
                }
            }
            rssItem._id = id;

            return(rssItem);
        }