isValidRss CFC

I was mucking around last night after finding out my feed wasnt valid, and created a validation CFC. The code is simple, but its just an idea if anyone wants to play around with it. It returns a boolean result, so i was thinking if it returns TRUE, then display "valid rss image" else "invalid, please email webmaster"? Here's the code for it, or if you want you can download it

<cfcomponent displayname="Check if valid RSS feed" hint="I take a URL and check it against ATOM to see if it is valid">
   <cffunction name="isValidRss" access="public" returntype="string" displayname="isValidRss" hint="I check an RSS Feed to see if its valid">
      
      <cfset var validationResult = FALSE>
      
      <cfargument name="rssUrl" type="string" required="true">
      
      <!--- Go of and validate the feed --->
      <cfhttp
         method="get"
         url="http://feedvalidator.org/check?url=#rssUrl#"
         resolveurl="yes"
         throwonerror="yes">

   
      <cfif findNoCase("Congratulations!", cfhttp.FileContent)>
         <cfset validationResult = TRUE>
      </cfif>
   
      <cfreturn validationResult>
   </cffunction>
</cfcomponent>

Comments (0) Print Send del.icio.us Digg It! Linking Blogs

836 Views | Posted At : February 21, 2004 9:58 AM | Posted By : Andy Jarrett
Related Categories: ColdFusion

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)