Justin Etheredge posted a list of blogs that he follows. He also posted a snippet of LINQ that converted his OPML file to a simple unordered HTML list. He encouraged his readership to let him know if there are any really good blogs he was missing. I was curious to see which blogs he reads that I have not yet subscribed to. I tweaked his LINQ slightly to output blogs that were in his OPML file, but not in mine.
var doc1 = XDocument.Load("http://media.codethinked.com/downloads/Opml.xml");
var doc2 = XDocument.Load("http://services.newsgator.com/ngws/svc/opml.aspx?uid=134891&mid=1");
var result = new XElement("ul",
from d1 in doc1.Elements("opml").Elements("body").Elements("outline")
join d2 in doc2.Elements("opml").Elements("body").Elements("outline")
on d1.Attribute("htmlUrl").Value equals d2.Attribute("htmlUrl").Value into d3
from d2 in d3.DefaultIfEmpty()
where d2 == null
select
new XElement("li",
new XElement("a",
new XAttribute("href", d1.Attribute("htmlUrl").Value), d1.Attribute("text").Value
),
" ",
new XElement("a",
new XAttribute("href", d1.Attribute("xmlUrl").Value), "RSS"
)
)
);
using (var xw = XmlWriter.Create("diff.xml", new XmlWriterSettings { Indent = true }))
{
result.WriteTo(xw);
}
diff.xml will contain blogs present in doc1 but not present in doc2. This is by no means perfect so don’t cry if it includes a few entries present in both or doesn’t work with your OPML. You could easily see which blogs both Justin and I read by changing the where clause.
Several readers wrote to Justin asking how he could possibly keep up with that many blogs. I only spend about 20 minutes a day reading through new posts. Only autonomous coding machines post everyday, so as long as I don’t lapse for more than a day or two it isn’t a problem keeping up. I also skim long posts and flag them for a more thorough reading later. Most of my subscriptions focus on .Net development but I have a few outliers like Zed Shaw’s blog. It can make for an extremely entertaining read (as long as you are not the subject of his attentions :).