Пример #1
0
        /// <summary>
        /// RSS all versions
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private static RssSchema ParseItem(XElement item)
        {
            var rssItem = new RssSchema();

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

            string description = item.GetSafeElementString("description");

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

            rssItem.Summary = Utility.DecodeHtml(description).Trim().Truncate(500, true);
            rssItem.Summary = RssHelper.SanitizeString(rssItem.Summary);
            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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        /// <summary>
        /// RSS all versions
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private static RssSchema ParseItem(XElement item)
        {
            var rssItem = new RssSchema();
            rssItem.Title = item.GetSafeElementString("title").Trim();
            rssItem.FeedUrl = item.GetSafeElementString("link");

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

            rssItem.Summary = Utility.DecodeHtml(description).Trim().Truncate(500, true);
            rssItem.Summary = RssHelper.SanitizeString(rssItem.Summary);
            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;
        }
Пример #4
0
        /// <summary>
        /// RSS all versions
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        private static RssSchema ParseItem(XElement item)
        {
            var rssItem = new RssSchema();

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

            string content = item.GetSafeElementString("encoded", "http://purl.org/rss/1.0/modules/content/");

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


            string description = item.GetSafeElementString("content");

            rssItem.Content = string.IsNullOrEmpty(content) ? RssHelper.SanitizeString(description) : RssHelper.SanitizeString(content);

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

            rssItem.Summary = RssHelper.SanitizeString(rssItem.Summary);


            return(rssItem);
        }
Пример #5
0
        private static RssSchema GetRssSchema(XElement item)
        {
            RssSchema rssItem = new RssSchema
            {
                Title = 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;
        }