Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--- Use cfhttp to GET an RSS feed (CF7 and up) --->
- <cftry>
- <cfhttp
- url="http://path.to/feed"
- method="GET" resolveurl="yes" timeout="10">
- </cfhttp>
- <cfset Feed = XMLParse(CFHTTP.FileContent)>
- <cfcatch type="any"><!--- An error occurred --->
- <cfset Feed = "">
- </cfcatch>
- </cftry>
- <!--- Use cfdump to display the result xml to fine tune what you want to output --->
- <cfdump var="#Feed#">
- <!--- Use this to output the resulting feed wherever you want --->
- <cfif isDefined("Feed") AND isXMLDoc(Feed)>
- <!--- Output 6 items from the feed (assumes there's at least 6 items) --->
- <cfloop index="x" from="1" to="6"><p><cfoutput>
- <a href="#Feed.rss.channel.item[x].link.xmlText#">
- #Feed.rss.channel.item[x].title.xmlText#
- </a><br />
- <small class="nowrap">#DateFormat(Feed.rss.channel.item[x].pubDate.xmlText, 'mmm d, yyyy')#</small>
- </cfoutput></p>
- </cfloop>
- <cfelse>
- <p>Feed is temporarily unavailable.</p>
- </cfif>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement