コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Rss10FeedItem"/> class.
        /// Reads a rss 1.0 feed item based on the xml given in item
        /// </summary>
        /// <param name="item">feed item as xml</param>
        public Rss10FeedItem(XElement item)
            : base(item)
        {
            this.DC = new DublinCore(item);
            this.Sy = new Syndication(item);

            this.About       = item.GetAttribute("rdf:about").GetValue();
            this.Description = item.GetValue("description");
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Rss20Feed"/> class.
        /// Reads a rss 2.0 feed based on the xml given in channel
        /// </summary>
        /// <param name="feedXml">the entire feed xml as string</param>
        /// <param name="channel">the "channel" element in the xml as XElement</param>
        public Rss20Feed(string feedXml, XElement channel)
            : base(feedXml, channel)
        {
            this.Description          = channel.GetValue("description");
            this.Language             = channel.GetValue("language");
            this.Copyright            = channel.GetValue("copyright");
            this.ManagingEditor       = channel.GetValue("managingEditor");
            this.WebMaster            = channel.GetValue("webMaster");
            this.Docs                 = channel.GetValue("docs");
            this.PublishingDateString = channel.GetValue("pubDate");
            this.LastBuildDateString  = channel.GetValue("lastBuildDate");
            this.ParseDates(this.Language, this.PublishingDateString, this.LastBuildDateString);

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

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

            this.Sy        = new Syndication(channel);
            this.Generator = channel.GetValue("generator");
            this.TTL       = channel.GetValue("ttl");
            this.Image     = new Rss20FeedImage(channel.GetElement("image"));
            this.Cloud     = new FeedCloud(channel.GetElement("cloud"));
            this.TextInput = new FeedTextInput(channel.GetElement("textinput"));

            var skipHours = channel.GetElement("skipHours");

            if (skipHours != null)
            {
                this.SkipHours = skipHours.GetElements("hour")?.Select(x => x.GetValue()).ToList();
            }

            var skipDays = channel.GetElement("skipDays");

            if (skipDays != null)
            {
                this.SkipDays = skipDays.GetElements("day")?.Select(x => x.GetValue()).ToList();
            }

            var items = channel.GetElements("item");

            foreach (var item in items)
            {
                this.Items.Add(new Rss20FeedItem(item));
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Rss091Feed"/> class.
        /// Reads a rss 0.91 feed based on the xml given in channel
        /// </summary>
        /// <param name="feedXml">the entire feed xml as string</param>
        /// <param name="channel">the "channel" element in the xml as XElement</param>
        public Rss091Feed(string feedXml, XElement channel)
            : base(feedXml, channel)
        {
            this.Description    = channel.GetValue("description");
            this.Language       = channel.GetValue("language");
            this.Image          = new Rss091FeedImage(channel.GetElement("image"));
            this.Copyright      = channel.GetValue("copyright");
            this.ManagingEditor = channel.GetValue("managingEditor");
            this.WebMaster      = channel.GetValue("webMaster");
            this.Rating         = channel.GetValue("rating");

            this.PublishingDateString = channel.GetValue("pubDate");
            this.PublishingDate       = Helpers.TryParseDateTime(this.PublishingDateString);

            this.LastBuildDateString = channel.GetValue("lastBuildDate");
            this.LastBuildDate       = Helpers.TryParseDateTime(this.LastBuildDateString);

            this.Docs = channel.GetValue("docs");

            this.TextInput = new FeedTextInput(channel.GetElement("textinput"));

            this.Sy = new Syndication(channel);

            var skipHours = channel.GetElement("skipHours");

            if (skipHours != null)
            {
                this.SkipHours = skipHours.GetElements("hour")?.Select(x => x.GetValue()).ToList();
            }

            var skipDays = channel.GetElement("skipDays");

            if (skipDays != null)
            {
                this.SkipDays = skipDays.GetElements("day")?.Select(x => x.GetValue()).ToList();
            }

            var items = channel.GetElements("item");

            AddItems(items);
        }