I found the answer after some trial and error and digging around!

It turns out, this character which is creating problem is something called
as Byte-Order-Mark and in an XML document, it is used to flag the encoding
type of the XML. Unfortunately, ColdFusion does not appreciate the use of
this Byte-Order-Mark, or BOM. In order to get this kind of XML feed to play
nicely with ColdFusion, we have to remove the BOM before we parse the
document. Luckily, getting rid of this requires nothing more than a simple
regular expression that strips out all characters before the first bracket.
Source and credit goes to:
http://blog.webvirtue.com/2009/05/coldfusion-xml-parsing.html

Finally here is the code that worked:
<cfhttp url="http://www.empiretheatres.com/rss/showtimes/43";
method="get"></cfhttp>
<cfset RSS = REReplace( cfhttp.filecontent, "^[^<]*", "", "all" )>
<cfset objRSS = xmlParse(RSS)>

Rick
Webenergy
www.webenergy.ca

-----Original Message-----
From: Rick Sanders [mailto:c...@webenergy.ca] 
Sent: Tuesday, January 25, 2011 10:57 PM
To: cf-talk
Subject: Parsing RSS feeds


Hey all,

 

I have code for parsing feeds that works very well on several feeds.

                  <cfhttp
url="http://rss.cbc.ca/lineup/canada-novascotia.xml " method="get"></cfhttp>

                  <cfset objRSS = xmlParse(cfhttp.filecontent)>

<cfoutput>#objRSS#</cfoutput>

<cfdump var="#objRSS#">

 

However, when I use the same code to parse the following feed it causes an
error:

                  <cfhttp
url="http://www.empiretheatres.com/rss/showtimes/43"; method="get"></cfhttp>

                  <cfset objRSS = xmlParse(cfhttp.filecontent)>

<cfoutput>#objRSS#</cfoutput>

<cfdump var="#objRSS#">

 

The error:


Content is not allowed in prolog. 

                

The error occurred in E:\Websites\ConnectNS\testrss.cfm: line 11

 

9 : <p>Empire Theatres RSS:</p>

10 :                   <cfhttp
url="http://www.empiretheatres.com/rss/showtimes/43"; method="get"></cfhttp>

11 :                   <cfset objRSS = xmlParse(cfhttp.filecontent)>

12 : <cfoutput>#objRSS#</cfoutput>

13 : <cfdump var="#objRSS#">

 

Can anyone help point me in the right direction? I'm perplexed! Google,
Yahoo, and the browser parse the feed fne!

 

Thanks,

 

Rick

Webenergy

www.webenergy.ca






~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:341296
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to