CFFeed Quirkiness With Some ITunes Feeds

While working on a site recently, I wanted to pull some data from an RSS feed to load into a page. A pretty simple thing to do, thanks to ColdFusion's lovely CFFEED tag. I mean what more can you ask for – one line of code turns any RSS feed into a nice loopable query. Yay! So I write up the code (for the purposes of this article, I'm using a stand in feed similar to the one I needed to pull in to avoid NDA issues 🙂 )…

<cffeed source="" query="qMyFeed" />
<cfdump var="#qMyFeed#" top="10" />

and run it…

What? I checked the feed with W3C's XML validator and it's all good. So WTF? I download the XML and look at it manually – everything looks kosher. But CFFEED no likey at all. So I Google around a bit and discovered, thanks to some old posts from Ray Camden and Julian at CFSimplicity what the problem is.

It wasn't the feed at all, at least not really. See said feed was for a podcast – with iTunes metadata included. In my case, the feed was being hit by the more specific issue noted in the latter article: the duration is represented in seconds. This is perfectly acceptable per the iTunes spec, but CFFEED wouldn't take it. Both filed bug reports with Adobe (#3043798 and 3043534), for CF 9, but Adobe closed them both with "not enough time."

So I redid the code to use the "old" style way of reading the feed. More lines of code, but at least it works.

<cfset qMyFeed = QueryNew("id,title,link,description,pubdate", "VARCHAR,VARCHAR,VARCHAR,VARCHAR,DATE") />
<cfhttp url="" charset="utf-8" />
<cfset myFeedContent = XMLParse(cfhttp.fileContent) />
<cfset thisRow = 1 />
<cfloop index="thisEpisode" array="">
   <cfset QueryAddRow(qMyFeed, 1) />
   <cfset QuerySetCell(qMyFeed, "id", thisEpisode.guid.XmlText, thisRow) />
   <cfset QuerySetCell(qMyFeed, "title", thisEpisode.title.XmlText, thisRow) />
   <cfset QuerySetCell(qMyFeed, "link",, thisRow) />
   <cfset QuerySetCell(qMyFeed, "description", thisEpisode.description.XmlText, thisRow) />
   <cfset QuerySetCell(qMyFeed, "pubdate", DateFormat(thisEpisode.pubDate.XmlText, "mmmm d, yyyy") & " " & TimeFormat(thisEpisode.pubDate.XmlText, "hh:mm:dd tt"), thisRow) />    
   <cfset thisRow += 1 />
<cfquery name="qMyFeed" dbtype="query">
   SELECT id, title, link, description, pubdate
   FROM qMyFeed
  ORDER BY pubdate DESC
<cfdump var="#qMyFeed#" top="10" />

I have no idea if this was fixed in ColdFusion 10 or if Railo has the same bug, as I don't have access to either. For ColdFusion 8 and 9, though, it's a bug that is very unlikely to be fixed since 8 is no longer supported and 9 will be heading that way soonish.