Lots of ways to do the same thing
Sep 28th, 2006 by Karen
I’ve been posting off and on about ways to transform an RSS or Atom feed into HTML using an XSLT, and Coldfusion. However, I failed to mention that you can also use the DOM and Coldfusion to make the transform happen. Here is a working example that does RSS 1.0, RSS 2.0, and Atom 1.0 feeds.
<cfhttp url="http://www.atomenabled.org/atom.xml" method="get" resolveurl="no" /> <cfset feed = XMLParse(cfhttp.filecontent)> <!--- get an array of items from the appropriate feed type ---> <cfif feed.XmlRoot.XMLName eq "rdf:RDF"> <cfset items = XMLSearch(feed, "//:item")> <cfelseif feed.XmlRoot.XMLName eq "feed"> <cfset items = XMLSearch (feed, "/:feed/:entry")> <cfelse> <cfset items = XMLSearch(feed, "/rss/channel/item")> </cfif> <ul> <cfloop from="1" to="#arrayLen(items)#" index="i"> <cfoutput> <li><a xhref="http://www.librarywebchic.net/wordpress/#items[i].link.xmltext#">#items[i].title.xmltext#</a></li> </cfoutput> </cfloop> </ul>
The url for the feed you want to parse goes in the line
<cfhttp url="http://www.atomenabled.org/atom.xml" method="get" resolveurl="no" />
One strange thing I can’t figure out with this method is why in the XMLSearch function of Coldfusion treats namespaces in XPath differently than namespaces in XPath are treated when you do a transform with XSLT. There is a interesting post that talks about this here. The post makes sense. Ie. okay if you see this then there is no namespace qualifier. However, when using XPath in my XSLTs I have to use a namespace qualifier. Maybe that is because at the beginning of my XSLT I defined a namespace qualifier for Atom? When I was working on the XSLTs I discovered that if a namespace qualifier existed in the XML document being transformed then it had to exist in the XSLT as well. Still trying to make sense of all this but I’m slowly gaining more knowledge as I experiment.


I had soo many problems with coldfusion last year it was like i bought a faulty skud missle from the russians.
the massive decision of running it on linux or IIS can throw everything out of wack…
the “jrun” errors due to a handful of concurrent users drove me crazy. How Adobe / Macromedia took the beauty of coldfusion from Allaire and corrupted it is amazing. sorry for ranting.