Example #1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Element">XML element containing the item content</param>
 public Item(XmlElement Element)
 {
     if (Element == null)
         throw new ArgumentNullException("Element");
     if (!Element.Name.Equals("item", StringComparison.CurrentCultureIgnoreCase))
         throw new ArgumentException("Element is not an 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);
     }
     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);
     }
 }
Example #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="Element">XML element containing the item content</param>
 public Item(XmlElement Element)
 {
     if (Element.Name.Equals("item", StringComparison.CurrentCultureIgnoreCase))
     {
         foreach (XmlNode Child in Element.ChildNodes)
         {
             try
             {
                 if (Child.Name.Equals("title", StringComparison.CurrentCultureIgnoreCase))
                 {
                     Title = Child.InnerText;
                 }
                 else if (Child.Name.Equals("link", StringComparison.CurrentCultureIgnoreCase))
                 {
                     Link = Child.InnerText;
                 }
                 else if (Child.Name.Equals("description", StringComparison.CurrentCultureIgnoreCase))
                 {
                     Description = Child.InnerText;
                 }
                 else if (Child.Name.Equals("author", StringComparison.CurrentCultureIgnoreCase))
                 {
                     Author = Child.InnerText;
                 }
                 else if (Child.Name.Equals("category", StringComparison.CurrentCultureIgnoreCase))
                 {
                     Categories.Add(RSS.StripIllegalCharacters(Child.InnerText));
                 }
                 else if (Child.Name.Equals("enclosure", StringComparison.CurrentCultureIgnoreCase))
                 {
                     _Enclosure = new Enclosure((XmlElement)Child);
                 }
                 else if (Child.Name.Equals("pubDate", StringComparison.CurrentCultureIgnoreCase))
                 {
                     PubDate = DateTime.Parse(Child.InnerText);
                 }
                 else if (Child.Name.Equals("media:thumbnail", StringComparison.CurrentCultureIgnoreCase))
                 {
                     Thumbnail = new Thumbnail((XmlElement)Child);
                 }
                 else if (Child.Name.Equals("guid", StringComparison.CurrentCultureIgnoreCase))
                 {
                     GUID = new GUID((XmlElement)Child);
                 }
             }
             catch { }
         }
     }
 }