示例#1
0
        /// <summary>
        /// Provides the XML representation of the feed as an RSS 2.0 feed.
        /// </summary>
        /// <param name="format">Indicates whether the XML should be returned as an RSS feed or a newspaper view</param>
        /// <param name="useGMTDate">Indicates whether the date should be GMT or local time</param>
        /// <returns>the feed as an XML string</returns>
        public string ToString(NewsItemSerializationFormat format, bool useGMTDate)
        {
            var sb     = new StringBuilder("");
            var writer = new XmlTextWriter(new StringWriter(sb));

            WriteTo(writer, format, useGMTDate);

            writer.Flush();
            writer.Close();

            return(sb.ToString());
        }
示例#2
0
 /// <summary>
 /// Provides the XML representation of the feed as an RSS 2.0 feed.
 /// </summary>
 /// <param name="format">Indicates whether the XML should be returned as an RSS feed or a newspaper view</param>
 /// <returns>the feed as an XML string</returns>
 public string ToString(NewsItemSerializationFormat format)
 {
     return(ToString(format, true));
 }
示例#3
0
 /// <summary>
 /// Writes this object as an RSS 2.0 feed to the specified writer
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="format">indicates whether we are writing a FeedDemon newspaper or an RSS feed</param>
 /// <param name="useGMTDate">Indicates whether the date should be GMT or local time</param>
 public void WriteTo(XmlWriter writer, NewsItemSerializationFormat format, bool useGMTDate)
 {
     WriteTo(writer, format, useGMTDate, false);
 }
示例#4
0
        /// <summary>
        /// Writes this object as an RSS 2.0 feed to the specified writer
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="format">indicates whether we are writing a FeedDemon newspaper or an RSS feed</param>
        /// <param name="useGMTDate">Indicates whether the date should be GMT or local time</param>
        /// <param name="noDescriptions">Indicates whether the contents of RSS items should
        /// be written out or not.</param>
        public void WriteTo(XmlWriter writer, NewsItemSerializationFormat format, bool useGMTDate, bool noDescriptions)
        {
            //writer.WriteStartDocument();

            if (format == NewsItemSerializationFormat.NewsPaper)
            {
                //<newspaper type="channel">
                writer.WriteStartElement("newspaper");
                writer.WriteAttributeString("type", "channel");
                // NamespaceCore.Feeds_v2003 == "http://www.25hoursaday.com/2003/RSSBandit/feeds/"
                writer.WriteAttributeString("xmlns", NamespaceCore.BanditPrefix, null, NamespaceCore.Feeds_v2003);
                writer.WriteElementString("title", title);
            }
            else if (format != NewsItemSerializationFormat.Channel)
            {
                //<rss version="2.0">
                writer.WriteStartElement("rss");
                writer.WriteAttributeString("version", "2.0");
                writer.WriteAttributeString("xmlns", NamespaceCore.BanditPrefix, null, NamespaceCore.Feeds_vCurrent);
            }

            /* These are here because so many people cut & paste into blogs from Microsoft Word
             *          writer.WriteAttributeString("xmlns","v",null,"urn:schemas-microsoft-com:office:vml");
             *          writer.WriteAttributeString("xmlns","x",null,"urn:schemas-microsoft-com:office:excel");
             *          writer.WriteAttributeString("xmlns","o",null,"urn:schemas-microsoft-com:office:office");
             *          writer.WriteAttributeString("xmlns","w",null,"urn:schemas-microsoft-com:office:word");
             *          writer.WriteAttributeString("xmlns","st1",null,"urn:schemas-microsoft-com:office:smarttags");
             *          writer.WriteAttributeString("xmlns","st2",null,"urn:schemas-microsoft-com:office:smarttags");
             *          writer.WriteAttributeString("xmlns","asp",null,"http://www.example.com/asp");
             */

            //<channel>
            writer.WriteStartElement("channel");

            //<title />
            writer.WriteElementString("title", Title);

            //<link />
            writer.WriteElementString("link", Link);

            //<description />
            writer.WriteElementString("description", Description);

            //other stuff
            string[] optionals = new string[optionalElements.Count];
            optionalElements.Values.CopyTo(optionals, 0);
            foreach (var s in optionals)
            {
                writer.WriteRaw(s);
            }

            //<item />
            INewsItem[] items = new INewsItem[itemsList.Count];
            itemsList.CopyTo(items);
            foreach (var item in items)
            {
                writer.WriteRaw(item.ToString(NewsItemSerializationFormat.RssItem, useGMTDate, noDescriptions));
            }

            writer.WriteEndElement();

            if (format != NewsItemSerializationFormat.Channel)
            {
                writer.WriteEndElement();
            }

            //writer.WriteEndDocument();
        }
示例#5
0
 /// <summary>
 /// Writes this object as an RSS 2.0 feed to the specified writer
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="format">indicates whether we are writing a FeedDemon newspaper or an RSS feed</param>
 public void WriteTo(XmlWriter writer, NewsItemSerializationFormat format)
 {
     WriteTo(writer, format, true, false);
 }