/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Element">XML element containing the item content</param>

        public Item(XmlElement Element)
        {
            Contract.Requires <ArgumentNullException>(Element != null, "Element");
            Contract.Requires <ArgumentException>(Element.Name.Equals("item", StringComparison.CurrentCultureIgnoreCase), "Element is not a item");
            XmlNamespaceManager NamespaceManager = new XmlNamespaceManager(Element.OwnerDocument.NameTable);

            NamespaceManager.AddNamespace("media", "http://search.yahoo.com/mrss/");
            XmlNode Node = Element.SelectSingleNode("./title", NamespaceManager);

            if (Node != null)
            {
                Title = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./link", NamespaceManager);
            if (Node != null)
            {
                Link = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./description", NamespaceManager);
            if (Node != null)
            {
                Description = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./author", NamespaceManager);
            if (Node != null)
            {
                Author = Node.InnerText;
            }
            XmlNodeList Nodes = Element.SelectNodes("./category", NamespaceManager);

            foreach (XmlNode TempNode in Nodes)
            {
                Categories.Add(RSS.StripIllegalCharacters(TempNode.InnerText));
            }
            Node = Element.SelectSingleNode("./enclosure", NamespaceManager);
            if (Node != null)
            {
                Enclosure = new Enclosure((XmlElement)Node);
            }
            Node = Element.SelectSingleNode("./pubdate", NamespaceManager);
            if (Node != null)
            {
                PubDate = DateTime.Parse(Node.InnerText, CultureInfo.InvariantCulture);
            }
            Node = Element.SelectSingleNode("./media:thumbnail", NamespaceManager);
            if (Node != null)
            {
                Thumbnail = new Thumbnail((XmlElement)Node);
            }
            Node = Element.SelectSingleNode("./guid", NamespaceManager);
            if (Node != null)
            {
                GUID = new GUID((XmlElement)Node);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Element">XML representation of the channel</param>

        public Channel(XmlElement Element)
        {
            Contract.Requires <ArgumentNullException>(Element != null, "Element");
            Contract.Requires <ArgumentException>(Element.Name.Equals("channel", StringComparison.CurrentCultureIgnoreCase), "Element is not a channel");
            XmlNamespaceManager NamespaceManager = new XmlNamespaceManager(Element.OwnerDocument.NameTable);
            XmlNode             Node             = Element.SelectSingleNode("./title", NamespaceManager);

            if (Node != null)
            {
                Title = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./link", NamespaceManager);
            if (Node != null)
            {
                Link = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./description", NamespaceManager);
            if (Node != null)
            {
                Description = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./copyright", NamespaceManager);
            if (Node != null)
            {
                Copyright = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./language", NamespaceManager);
            if (Node != null)
            {
                Language = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./webmaster", NamespaceManager);
            if (Node != null)
            {
                WebMaster = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./pubdate", NamespaceManager);
            if (Node != null)
            {
                PubDate = DateTime.Parse(Node.InnerText, CultureInfo.InvariantCulture);
            }
            XmlNodeList Nodes = Element.SelectNodes("./category", NamespaceManager);

            foreach (XmlNode TempNode in Nodes)
            {
                Categories.Add(RSS.StripIllegalCharacters(TempNode.InnerText));
            }
            Node = Element.SelectSingleNode("./docs", NamespaceManager);
            if (Node != null)
            {
                Docs = Node.InnerText;
            }
            Node = Element.SelectSingleNode("./ttl", NamespaceManager);
            if (Node != null)
            {
                TTL = int.Parse(Node.InnerText, CultureInfo.InvariantCulture);
            }
            Node = Element.SelectSingleNode("./image/url", NamespaceManager);
            if (Node != null)
            {
                ImageUrl = Node.InnerText;
            }
            Nodes = Element.SelectNodes("./item", NamespaceManager);
            foreach (XmlNode TempNode in Nodes)
            {
                Items.Add(new Item((XmlElement)TempNode));
            }
        }