Archive

Posts Tagged ‘RSS’

Limit RSS to certain categories in WordPress.

December 19th, 2009 Jimmy No comments

If you’re like me, you may once in a while have something to write about that isn’t necessarily related to your overall blog topic. Take me for example. My blog is mainly about internet and application development (programming) however sometimes I find a really cool tip or trick that isn’t necessarily related, such as a howto for example. Using this code I can exclude those posts from my RSS feeds. That way my main RSS subscribers don’t get caught reading off-topic posts, but they are there if they want to read them on the site. I then include just the headlines of those posts on my extended recent posts sidebar widget.

Anyways enough of the blabbing on onto the code. This code excludes categories 35 and 45 from my RSS feeds. You can get the category ID’s on your category admin page in your WordPress dashboard.

add_filter('pre_get_posts', 'filterRSSQuery');
function filterRSSQuery($query) {
    if ( $query->is_feed ) {
        $query->set('cat', '-30,-45');
    }   

    return $query;
}
Categories: Programming Tags: , ,

RSS.NET – Read RSS feeds in .NET.

December 11th, 2009 Jimmy No comments

“RSS is a format for syndicating news and the content of news-like sites, including major news sites like Wired, news-oriented community sites like Slashdot, and personal weblogs. But it’s not just for news. Pretty much anything that can be broken down into discrete items can be syndicated via RSS: the “recent changes” page of a wiki, a changelog of CVS checkins, even the revision history of a book. Once information about each item is in RSS format, an RSS-aware program can check the feed for changes and react to the changes in an appropriate way.” – Mark Pilgrim

RSS.NET is an open-source .NET class library for RSS feeds. It provides a reusable object model for parsing and writing RSS feeds. It is fully compatible with RSS versions 0.90, 0.91, 0.92, and 2.0.1, implementing all constructs.

RSS is free to use in both commercial and non-commercial use. This is a library and is not a tool for end users to use. This has been tested under Visual Studio 2008 and SharpDevelop 3.0.

Categories: General Tags: ,

Implement an RSS reader into your .NET program.

December 6th, 2009 Jimmy No comments

If you’re looking for RSS support in your .NET application head over to RSSdotnet.com and download the latest RSS.NET library. They provide all the source code and API documents you need to add RSS into your program. I haven’t thoroughly reviewed the code but it does work pretty code and seems stable. I’m currently using it in a blog tool I am about to release but more on that later lets see some RSS.NET code!

Below is a very simple implementation on how you can use RSS.NET. Don’t forget to add the project to your solution and add a reference to that project! This should parse out my RSS feed and pause for each item.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rss;
namespace ConsoleRssTest
{
    class Program
    {
        static void Main(string[] args)
        {
            RssFeed feed = RssFeed.Read("http://feeds.feedburner.com/uniprogrammer");
            RssChannel channel = (RssChannel)feed.Channels[0];
            foreach (RssItem Ri in channel.Items)
            {
                Console.WriteLine(Ri.Title);
                Console.WriteLine(Ri.Link.AbsoluteUri);
                Console.WriteLine(Ri.Description);

                //This will let you read each feed as they come in....
                Console.WriteLine("Press any key too continue...");
                Console.ReadLine();

            }

        }
    }
}

Categories: Programming Tags: , , ,