コード例 #1
0
        private RssFeed(IFeed feed)
        {
            items = new List<RssItem>();
            title = feed.Title;
            link = feed.Link;
            description = feed.Description;
            path = feed.Path;
            lastWriteTime = feed.LastWriteTime;

            foreach (IFeedItem item in (IFeedsEnum)feed.Items)
            {
                RssItem rssItem =  new RssItem(item);

                // only add items that have enclosures
                if (rssItem.Enclosure != null)
                    items.Add(rssItem);
            }
        }
コード例 #2
0
        /// <summary>
        /// Private constructor to be used with factory pattern.  
        /// </summary>
        /// <exception cref="System.Xml.XmlException">Occurs when the XML is not well-formed.</exception>
        /// <param name="xmlNode">An XML block containing the RSSFeed content.</param>
        private RssFeed(XmlNode xmlNode)
        {
            XmlNode channelNode = xmlNode.SelectSingleNode("rss/channel");
            items = new List<RssItem>();
            title = channelNode.SelectSingleNode("title").InnerText;
            link = channelNode.SelectSingleNode("link").InnerText;
            description = channelNode.SelectSingleNode("description").InnerText;

            XmlNodeList itemNodes = channelNode.SelectNodes("item");
            foreach (XmlNode itemNode in itemNodes)
            {
                RssItem rssItem = new RssItem(itemNode);

                // only add items that have enclosures
                if (rssItem.Enclosure != null)
                    items.Add(rssItem);
            }
        }