示例#1
0
        /// <summary>
        /// Parses the xml document in order to retrieve the RSS items.
        /// </summary>
        private void ParseRssItems(XmlDocument xmlDoc)
        {
            _rssItems.Clear();
            XmlNodeList         nodes     = xmlDoc.SelectNodes("rss/channel/item");
            XmlNamespaceManager nsmanager = new XmlNamespaceManager(xmlDoc.NameTable);

            nsmanager.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");

            foreach (XmlNode node in nodes)
            {
                Rss.Items item = new Rss.Items();
                ParseDocElements(node, "title", ref item.Title);
                ParseDocElements(node, "description", ref item.Description);
                ParseDocElements(node, "link", ref item.Link);

                string date = null;
                ParseDocElements(node, "pubDate", ref date);
                DateTime.TryParse(date, out item.Date);
                ParseDocElements(node, "dc:creator", ref item.Creator, nsmanager);
                ParseDocElements(node, "comments", ref item.Comments);

                _rssItems.Add(item);
            }
        }
示例#2
0
        /// <summary>
        /// Parses the xml document in order to retrieve the RSS items.
        /// </summary>
        private void ParseRssItems(XmlDocument xmlDoc)
        {
            _rssItems.Clear();
            XmlNodeList nodes = xmlDoc.SelectNodes("rss/channel/item");
            XmlNamespaceManager nsmanager = new XmlNamespaceManager(xmlDoc.NameTable);
            nsmanager.AddNamespace("dc", "http://purl.org/dc/elements/1.1/");

            foreach (XmlNode node in nodes)
            {
                Rss.Items item = new Rss.Items();
                ParseDocElements(node, "title", ref item.Title);
                ParseDocElements(node, "description", ref item.Description);
                ParseDocElements(node, "link", ref item.Link);

                string date = null;
                ParseDocElements(node, "pubDate", ref date);
                DateTime.TryParse(date, out item.Date);
                ParseDocElements(node, "dc:creator", ref item.Creator, nsmanager);
                ParseDocElements(node, "comments", ref item.Comments);

                _rssItems.Add(item);
            }
        }