示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MediaRssFeedItem"/> class.
        /// Reads a new feed item element based on the given xml item
        /// </summary>
        /// <param name="item">the xml containing the feed item</param>
        public MediaRssFeedItem(XElement item)
            : base(item)
        {
            this.Comments             = item.GetValue("comments");
            this.Author               = item.GetValue("author");
            this.Enclosure            = new FeedItemEnclosure(item.GetElement("enclosure"));
            this.PublishingDateString = item.GetValue("pubDate");
            this.PublishingDate       = Helpers.TryParseDateTime(this.PublishingDateString);
            this.DC     = new DublinCore(item);
            this.Source = new FeedItemSource(item.GetElement("source"));

            var media = item.GetElements("media", "content");

            this.Media = media.Select(x => new Media(x)).ToList();

            var mediaGroups = item.GetElements("media", "group");

            this.MediaGroups = mediaGroups.Select(x => new MediaGroup(x)).ToList();

            var categories = item.GetElements("category");

            this.Categories = categories.Select(x => x.GetValue()).ToList();

            this.Guid        = item.GetValue("guid");
            this.Description = item.GetValue("description");
            this.Content     = item.GetValue("content:encoded")?.HtmlDecode();
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Rss20FeedItem"/> class.
        /// Reads a new feed item element based on the given xml item
        /// </summary>
        /// <param name="item">the xml containing the feed item</param>
        public Rss20FeedItem(XElement item)
            : base(item)
        {
            this.Comments = item.GetValue("comments");
            this.Author   = item.GetValue("author");
            if (String.IsNullOrEmpty(this.Author))
            {
                this.Author = item.GetValue("dc:creator");
            }
            this.Enclosure            = new FeedItemEnclosure(item.GetElement("enclosure"));
            this.PublishingDateString = item.GetValue("pubDate");
            this.PublishingDate       = Helpers.TryParseDateTime(this.PublishingDateString);
            this.DC     = new DublinCore(item);
            this.Source = new FeedItemSource(item.GetElement("source"));

            var categories = item.GetElements("category");

            this.Categories = categories.Select(x => x.GetValue()).ToList();

            this.Guid        = item.GetValue("guid");
            this.Description = item.GetValue("description");
            this.Content     = item.GetValue("content:encoded")?.HtmlDecode();
        }