/// <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(); }
/// <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"); 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(); if (this.ExtraData == null) { this.ExtraData = new Dictionary <string, string>(); } foreach (var i in item.DescendantNodes()) { var x = i as XElement; if (x != null) { if (this.ExtraData.ContainsKey(x.Name.LocalName)) { this.ExtraData[x.Name.LocalName] += ", " + x.Value; } else { if (x.Name.LocalName == "content") { var w = x.GetAttribute("width"); if (w != null) { var s = x.GetAttribute("url"); if (s != null) { if (this.ExtraData.ContainsKey("image" + w.Value) == false) { this.ExtraData.Add("image" + w.Value, "<img src='" + s.Value + "' >"); } } } } else { this.ExtraData.Add(x.Name.LocalName, x.Value); } } } } }