I always get a parse (XMLParse()) error when using XML feeds from Yahoo or NOAA
or other such XML / RSS data sources. I have narrowed down the problem to
three things:
1) The little "-" or "+" signs that are used to open and close the group.
2) Any "&" in any URL's in the XML text.
3) Any extranneaous data at the end of the XML data that is commented out like
"<!---generated by static php_rss_category ->" which is on all news feeds from
Yahoo.
I have fixed these problems by using several replace functions but this seems
really inefficient. Has anyone else come across this problem and is there an
easier way to deal with it? And most importantly why doesn't XMLParse()
handle this automatically?
Bob
<cfhttp url="http://rss.news.yahoo.com/rss/topstories"
method="get">
<cfset xml=CFHTTP.FileContent>
<cfset xmlfix = replace(xml, "&", "", "all")>
<cfset xmlfix = replace(xmlfix, "- ", "", "all")>
<cfset xmlfix = replace(xmlfix, "+ ", "", "all")>
<cfset xmlfix = replace(xmlfix, "<!", "", "all")>
<cfset xmlfix = replace(xmlfix, "->", "", "all")>
<cfset xmlfix = replace(xmlfix, "-generated by static php_rss_category -", "",
"all")>
<cfset xmlDoc = XMLParse(trim(xmlfix))>
mpwoodward - 25 Oct 2004 20:51 GMT
On 10/25/04 8:15 AM, in article cliu8v$mdt$1@forums.macromedia.com, "zbob99"
<webforumsuser@macromedia.com> wrote:
> I always get a parse (XMLParse()) error when using XML feeds from Yahoo or
> NOAA
> or other such XML / RSS data sources. I have narrowed down the problem to
> three things:
>
> 1) The little "-" or "+" signs that are used to open and close the group.
These aren't in the XML document itself. The browser just renders these
when it encounters an XML document that doesn't have an XSL stylesheet
applied to it.
> 2) Any "&" in any URL's in the XML text.
I just ran a test and these come through fine for me--as &
> 3) Any extranneaous data at the end of the XML data that is commented out
> like
> "<!---generated by static php_rss_category ->" which is on all news feeds from
> Yahoo.
If the comments are formatted correctly they shouldn't be an issue. This
particular one isn't but again, I just ran a test and get XML back fine from
the Yahoo link you provide below.
> I have fixed these problems by using several replace functions but this seems
> really inefficient. Has anyone else come across this problem and is there an
> easier way to deal with it? And most importantly why doesn't XMLParse()
> handle this automatically?
What exactly are you trying to do with this data? I just did the following
and it works fine:
<cfhttp url="http://rss.news.yahoo.com/rss/topstories" method="get" />
<cfset xml = CFHTTP.FileContent />
<cfset xml = XmlParse(xml) />
<cfdump var="#xml#" expand="yes" />
Granted you could combine lines 2 and 3, I'm just trying to go step by step
to make sure if it did blow up I'd know where. No errors for me. What
error do you get?
Matt

Signature
Matt Woodward
Team Macromedia Member - ColdFusion
lbryngel - 26 Oct 2004 20:13 GMT
zbob99 -
I just ran your code in ColdFusion 6.1 with Updater 1 (6,1,0,83762) taking
out the filters and it ran without error.
<cfhttp url="http://rss.news.yahoo.com/rss/topstories"method="get">
<cfset xml=CFHTTP.FileContent>
<cfset xmlDoc = XMLParse(trim(xml))>
<cfdump var="#xmlDoc#">
<cfoutput>#toString(xmlDoc)#</cfoutput>
<cfdump var="#xmlDoc#">
<cfoutput>#toString(xmlDoc)#</cfoutput>
What version are you running of Coldfusion and is there more code that I'm
missing to produce the error?
Thanks,
Lisa Bryngelson
Server Product Support Engineer
zbob99 - 29 Oct 2004 19:57 GMT
Yes. The problem was I was copying the XML output from the browser screen and
saving to file and then running the XMLParse on that file. Which is why I
getting those weird errors. It works fine, as you say, when it is run directly
on the RSS feed. Sorry for the confusion and thanks for the help. Bob