Ejemplo n.º 1
0
        /// <summary>
        /// Outputs a string ready for RSS
        /// </summary>
        /// <returns>A string formatted for RSS</returns>
        public override string ToString()
        {
            var ItemString = new StringBuilder();

            ItemString.Append("<item><title>").Append(Title).Append("</title>\r\n<link>")
            .Append(Link).Append("</link>\r\n<author>").Append(Author)
            .Append("</author>\r\n");
            foreach (string Category in Categories)
            {
                ItemString.Append("<category>").Append(Category).Append("</category>\r\n");
            }
            ItemString.Append("<pubDate>").Append(PubDate.ToString("r", CultureInfo.InvariantCulture)).Append("</pubDate>\r\n");
            if (Enclosure != null)
            {
                ItemString.Append(Enclosure.ToString());
            }
            if (Thumbnail != null)
            {
                ItemString.Append(Thumbnail.ToString());
            }
            ItemString.Append("<description><![CDATA[").Append(Description).Append("]]></description>\r\n");
            if (GUID != null)
            {
                ItemString.Append(GUID.ToString());
            }
            ItemString.Append("<itunes:subtitle>").Append(Title).Append("</itunes:subtitle>");
            ItemString.Append("<itunes:summary><![CDATA[").Append(Description).Append("]]></itunes:summary>");
            ItemString.Append("</item>\r\n");
            return(ItemString.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="Doc">XML element containing the item content</param>
        public Item(IXPathNavigable Doc)
            : this()
        {
            Contract.Requires <ArgumentNullException>(Doc != null, "Doc");
            var Element          = Doc.CreateNavigator();
            var NamespaceManager = new XmlNamespaceManager(Element.NameTable);

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

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

            foreach (XmlNode TempNode in Nodes)
            {
                Categories.Add(Utils.StripIllegalCharacters(TempNode.Value));
            }
            Node = Element.SelectSingleNode("./enclosure", NamespaceManager);
            if (Node != null)
            {
                Enclosure = new Enclosure(Node);
            }
            Node = Element.SelectSingleNode("./pubdate", NamespaceManager);
            if (Node != null)
            {
                PubDate = DateTime.Parse(Node.Value, CultureInfo.InvariantCulture);
            }
            Node = Element.SelectSingleNode("./media:thumbnail", NamespaceManager);
            if (Node != null)
            {
                Thumbnail = new Thumbnail(Node);
            }
            Node = Element.SelectSingleNode("./guid", NamespaceManager);
            if (Node != null)
            {
                GUID = new GUID(Node);
            }
        }