I've been trying to parse this rss feed
http://www.economicnews.ca/cepnews/wire/rss/custom?u=camagazine&p=39d7g7d9
Here is the code I'm using:
<!--- Retrieve the RSS document --->
<cfhttp url="
http://www.economicnews.ca/cepnews/wire/rss/custom?u=camagazine&p=39d7g7d9"
method="get">
<cfhttpparam type="Header" name="Accept-Encoding"
value="deflate;q=0">
<cfhttpparam type="Header" name="TE"
value="deflate;q=0">
</cfhttp>
<!--- Validation flag --->
<cfset XMLVALIDATION = true>
<cftry>
<!--- Create the XML object --->
<cfset objRSS = xmlParse(cfhttp.filecontent)>
<cfcatch type="any">
<!--- If the document retrieved in the CFHTTP
is not valid set the validation flag to false. --->
<cfset XMLVALIDATION = false>
</cfcatch>
</cftry>
<cfif XMLVALIDATION>
<!--- If the validation flag is true continue parsing
--->
<!--- Set the XML Root --->
<cfset XMLRoot = objRSS.XmlRoot>
<!--- Retrieve the document META data --->
<cfset doc_title = XMLRoot.channel.title.xmltext>
<cfset doc_link = XMLRoot.channel.link.xmltext>
<cfset doc_description =
XMLRoot.channel.description.xmltext>
<cfset doc_content = XMLRoot.channel.content.xmltext>
<!--- Output the meta data in the browser --->
<!-- <cfoutput>
<b>Title</b>: #doc_title#<br/>
<b>Link</b>: #doc_link#<br/>
<b>Description</b>:
#doc_description#<br/><br/>
</cfoutput> -->
<!--- Retrieve the number of items in the channel --->
<cfset Item_Length = arraylen(XMLRoot.channel.item)>
<!--- Loop through all the items --->
<cfloop index="itms" from="1" to="2">
<!--- Retrieve the current Item in the loop --->
<cfset tmp_Item = XMLRoot.channel.item[itms]>
<!--- Retrieve the item data --->
<cfset item_title = tmp_item.title.xmltext>
<cfset item_link = tmp_item.link.xmltext>
<cfset item_description = tmp_item.description.xmltext>
<cfset item_content = tmp_item.content.xmltext>
<!--- Output the items in the browser --->
<cfoutput>
<a href="#item_link#"
target="_blank"><strong>#item_title#</strong></a><br/>
#item_description#<br/><br/><br />
#item_content#
</cfoutput>
</cfloop>
<cfelse>
<!--- If the validation flag is false display error
--->
Invalid XML/RSS object!
</cfif>
But it gives me the following error:
Element CHANNEL.CONTENT.XMLTEXT is undefined in XMLROOT.
The error occurred in
E:\inetpub\wwwroot\cica\shane_upload_folder\rss_parse.cfm: line 31
29 : <cfset doc_link = XMLRoot.channel.link.xmltext>
30 : <cfset doc_description =
XMLRoot.channel.description.xmltext>
31 : <cfset doc_content =
XMLRoot.channel.content.xmltext>
I've checked and re-checked, I've done dumps and the content
is there, so I'm not sure what the heck it doesn't like. Thoughts
anyone?