Feed Synchronization one liner

40 sec read

One of the things that troubled me for quite a long time now was the fact that my RSS feeds were out of sync between my home and work PCs. That’s because I kept forgetting to add the feeds I was subscribing from one PC to the other. And of course I didn’t want to delete all feeds from either one of them cause that could result in loosing some.

I had to build a small utility that, using XML DOM and XPath, would read my aggregators’ OPML files and synchronize them. The problem was that I didn’t have time for such a program.

With Linq to XML though things got a lot easier, so much easier that I can now write a single line of code that will find out which feed subscriptions are not contained from an OPML file to another like so:

var feedQuery = 
    from f in XElement.Load("subset.opml").Descendants("outline")
    where f.Attribute("xmlUrl") != null &&
          (from XElement o in XElement.Load("Full.opml").Descendants("outline")
           where o.Attribute("xmlUrl") != null
           select (string)o.Attribute("xmlUrl")).ToList().Contains(((string)f.Attribute("xmlUrl")))
    select f;

So I’m finally going to have all my feeds synced ….

ASP.NET Tips and Tricks

I’m starting a new line of blog posts in which I’m going to give out a few tips and tricks I’ve picked up during...
kpantos
3 min read

C# 3.0 Query Expression Translation Cheat Sheet

Bart de Smet has released a very usefully query expression translation cheat sheet this is an excellent resource if you’re into Linq and want...
kpantos
6 sec read

Day3 at TechEd Barcelona

If you had only had tine for just one Session in this year’s TechEd then I would definitely recommend Mike Taulty’s one on Linq...
kpantos
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *