Back to "RSS Feeds..."

This is a viewer only at the moment see the article on how this works.

To update the preview hit Ctrl-Alt-R (or ⌘-Alt-R on Mac) or Enter to refresh. The Save icon lets you save the markdown file to disk

This is a preview from the server running through my markdig pipeline

ASP.NET Imported mostlylucidcouk Web Development XML

RSS Feeds...

Friday, 12 March 2004

Rob Howard preguntó cómo otras personas estaban haciendo RSS feeds, así que esto ha sido un problema para mí recientemente, donde tuve que generar RSS feeds para los objetos existentes. Usé una pequeña colección de clases para hacer esto que he subido aquí, aquí hay un ejemplo rápido de cómo estoy currenlty utilizando estos (nombres eliminados para proteger a los inocentes) - nota, estos no son Rss EXACT, he añadido un campo, xsdDate, 'porque necesitaba esto para una transformación (no romper lectores teniendo este bit adicional aunque!), Voy a actualizar esto más tarde con un poco más de información sobre estos ... esencialmente pasa a través de los elementos en un objeto (mal) llamado ItemFeedStruct y crea una entrada para cada uno ... haciendo un ToString() entonces me da el feed RSS completo para esto. Nota, Yo no escribí las clases RSS originalmente, pero no puedo encontrar el enlace a la persona que hizo - si ot era usted, dejar un comentario! Adam Kinney's desde el GotDotNet Workspace

        private void BindRssControls(ItemFeedStruct theFeed)
        {
            
            string thisUrl = "http://" + Request.Url.Host + Application["AppPath"];
            RSSFeed rFeed = new RSSFeed("Latest  " + cts.ContentTypeName,thisUrl,"Feed for  Communities");
    
            for(int i=0; i < theFeed.items.Length; i++)
            {
                RSSItem rItem;
                if(_contentType != ctl.ForumThreads)
                {
                    rItem = new RSSItem(Server.HtmlEncode(theFeed.items[i].ItemTitle),Server.HtmlEncode(theFeed.items[i].ShortDescription));    
                }
                else
                {
                    string longDesc= theFeed.items[i].LongDescription;
                    if(longDesc.IndexOf(' ') > -1)
                    {
                        longDesc= longDesc.Substring(0,longDesc.LastIndexOf(' '));
                    }
                    rItem = new RSSItem(Server.HtmlEncode(theFeed.items[i].ItemTitle),Server.HtmlEncode(longDesc));    
                }
                rItem.PubDate = theFeed.items[i].ItemValidFrom.ToUniversalTime().ToString("r");
                rItem.XsdDate = theFeed.items[i].ItemValidFrom.ToString("s");
                rItem.Guid = theFeed.items[i].itemId.ToString();
                rItem.Link = Server.HtmlEncode(theFeed.items[i].ViewUrl);
                rItem.Author = Server.HtmlEncode(theFeed.items[i].AuthorName);
                RSSCategoryCollection rCat = new RSSCategoryCollection();
                rCat.Add(new RSSCategory(Server.HtmlEncode(theFeed.items[i].Category)));
                rItem.Categories = rCat;
                rFeed.Items.Add(rItem);
            }
            Response.ContentType = "text/xml";
            Page.EnableViewState = false;
            RssLiteral.Text = rFeed.ToString();
        }
logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.