March 23, 2006
|
Comment feed
|
11966 hit(s)
I added a comment feed to the blog. I see this on just a few blogs, as reflected in my aggregator (RSSBandit):

(Courtesy of ComputerZen.com in this case.)
It was not 100% clear to me what exactly to implement, elements wise. I got the original comment API spec from the Well-Formed Web site. I also poked around in a couple of existing comment feeds, including Scott Hanselman's comment feed and the comment feed from the ASP.NET Web logs site. The three sources didn't completely agree about what elements to provide, but as Joe Gregorio says on the Well-Formed Web site:... the contents of the 'item' element are guided by the RSS 2.0 specification, which states that all elements are optional, but requires that at least one of 'title' or 'description' are present. All right, then.
If you want to see what it looks like, have a peek at this feed:
http://www.mikepope.com/blog/blogcommentsfeed.ashx?id=1457
You might note that this feed is implemented as an ASP.NET HTTP handler, which conforms to a, er, suggestion from Nikhil. (The main feed is implemented as a Web service.) The extension is .ashx, the default handler. One day Real Soon Now I'll get around to remapping the .rss extension to the ASP.NET ISAPI and configuring the blog app to handle that.
To expose the comment feed, I updated the main feed (http://mikepope.com/blog/blogfeed.asmx/GetRSS?) to include a couple of new elements, including <wfw:commentRss/> and <slash:comments/> . This required that I learn how to specify a namespace and prefix for an element ... you learn something new every day, it seems.
So this was all fun and stuff. I'll describe another day how I went about creating the RSS for this, which I'll note for now did not involve creating an XmlDocument and populating it element by element.
One slight problem, though: as at this moment, my aggregator is not actually recognizing that I have a comment feed available. I've looked over the main feed, and it seems to be listing the comment feed URL properly. And the comment feed seems to be well-formed and all that. So I don't know what's wrong exactly, unless it's a problem with cache latency or something. Or I'm fundamentally not understanding how this comment-feed thing works.
If you've got any insights, I'd sure like to hear them. Or, of course, if this actually works in your aggregator, or -- horrors -- if it horks things up.
Update Ok, I got it. Once again I am flummoxed by dynamically creating XML elements. I ended up having to do something like this:Dim commentRSS, commentCount As XmlElement commentRss = doc.CreateElement("wfw", "commentRss", "http://wellformedweb.org/CommentAPI/") commentCount = doc.CreateElement("slash", "comments", "http://purl.org/rss/1.0/modules/slash/") IOW, I had to pass the XML namespace URI explicitly in the create method even though all the namespaces are declared in the <rss/> block at the top of the XML file. It'd be nice not to have to do this. Also, I obviously need to understand more about XML manipulation. All the more then, for doing the comment feed the way I did, as you'll see ...
|