• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 538
  • Last Modified:

Coldfusion RSS Feed Issue

For some reason, my coldfusion RSS feed was working fine validating 2 days ago...Now I'm getting two errors and I'm not sure why.

line 371, column 89: guid values must not be duplicated within a feed: http://www.blahblah.com/career.cfm?jobid=123456 (4 occurrences) [help]

... blahblah.com/career.cfm?jobid=123456</guid>

In addition, interoperability with the widest range of feed readers could be improved by implementing the following recommendation.

*

line 16, column 3: Misplaced Item (226 occurrences) [help]

<item>

I checked my feed to make sure there were no repeat occurrences of 19886, and it wasn't. The only common thing I found was there was some repeating titles on some of the other entries in the feed, but the values are different in all of them that's within the GUID field. So I'm not sure why it says repeat occurrences, besides the title...

Also, the item tag misplace is also another weird issue that popped up....The feed itself looks fine. Any help would be most appreciated.


<cfsavecontent variable="theXML">
<cfoutput><?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
       <title>RSS</title>
       <link>http://www.blahblah.com</link>
       <description>Latest Postings</description>
       <language>en-us</language>
       <copyright>Copyright 2009 Blah Blah Online</copyright>
       <lastBuildDate>#dateformat(now(), "ddd, dd mmm yyyy")# #timeformat(now(), "HH:mm:ss")# GMT</lastBuildDate>
       <image>
            <title>Blah Blah RSS</title>
            <url>http://www.blahblah.com/logorss.jpg</url>
            <link>http://www.blahblah.com</link>
       </image>
</cfoutput>
<cfscript>
 
function stripHTML(str) {
str = reReplace(str, "<.*?>","","all");
//get partial html in front
str = reReplace(str, "^.*?>","");
//get partial html at end
str = reReplace(str, "<.*$","");
//replace html entities
str = reReplace(str, "&[\w]*;", "", "all");
return str;
}
</cfscript>
<cfoutput query="Getjob">
   <item>
         <title><![CDATA[ #title# ]]></title>
	<pubDate>#dateformat(now(), "ddd, dd mmm yyyy")# #timeformat(now(), "HH:mm:ss")# GMT</pubDate>
         <description>#stripHTML(description)#</description>
         <guid isPermaLink="true">http://www.blahblah.com/career.cfm?jobid=#jobid#</guid>
   </item>
   </cfoutput>
<cfoutput>
<atom:link href="http://www.blahblah.com/rss.xml" rel="self" type="application/rss+xml" />
</channel>
</rss>
</cfoutput>
</cfsavecontent>
<cffile action="write" file="Z:\\Blah\www.blahblah.com\www\rss.xml" output="#theXml#">

Open in new window

0
Phylox
Asked:
Phylox
  • 5
  • 4
1 Solution
 
azadisaryevCommented:
it's really hard to say what might have gone wrong without seeing the actual feed...
can you post a link to your feed xml? also, which validator are you using?

some more suggestions:
- move your function to outside of the feed generating block - there's no need for it to be there. move it to before <cfsavecontent> tag.
- you may also want to surround all your code with <cfprocessingdirective suppresswhitespace="true"> to prevent any extra whitespace generated by cf...
- you may also want to use xmlformat() on your description to escape any characters that need to be escaped to make a valid xml string: <description>#xmlformat(stripHTML(description))#</description>

Azadi
0
 
PhyloxAuthor Commented:
Hello Azad,

Hi I have a edited version of the xml - Hope this helps - It's located here

http://cfx.pastebin.com/d5b15dec3

The "4 occurrences" that the guid must not be duplicated value is on jobid 19886.  

I also modified the code to the suggestions you have made - here is the new version.
<cfsavecontent variable="theXML">
<cfoutput><?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
       <title>RSS</title>
       <link>http://www.blahblah.com</link>
       <description>Latest Postings</description>
       <language>en-us</language>
       <copyright>Copyright 2009 Blah Blah Online</copyright>
       <lastBuildDate>#dateformat(now(), "ddd, dd mmm yyyy")# #timeformat(now(), "HH:mm:ss")# GMT</lastBuildDate>
       <image>
            <title>Blah Blah RSS</title>
            <url>http://www.blahblah.com/logorss.jpg</url>
            <link>http://www.blahblah.com</link>
       </image>
</cfoutput>
<cfoutput query="Getjob">
   <item>
<cfprocessingdirective suppresswhitespace="true"> 
         <title><![CDATA[ #title# ]]></title>
        <pubDate>#dateformat(now(), "ddd, dd mmm yyyy")# #timeformat(now(), "HH:mm:ss")# GMT</pubDate>
         <description>#xmlformat(stripHTML(description))#</description>
         <guid isPermaLink="true">http://www.blahblah.com/career.cfm?jobid=#jobid#</guid>
</cfprocessingdirective>
   </item>
   </cfoutput>
<cfoutput>
<atom:link href="http://www.blahblah.com/rss.xml" rel="self" type="application/rss+xml" />
</channel>
</rss>
</cfoutput>
<cfscript>
 
function stripHTML(str) {
str = reReplace(str, "<.*?>","","all");
//get partial html in front
str = reReplace(str, "^.*?>","");
//get partial html at end
str = reReplace(str, "<.*$","");
//replace html entities
str = reReplace(str, "&[\w]*;", "", "all");
return str;
}
</cfscript>
</cfsavecontent>
<cffile action="write" file="Z:\\Blah\www.blahblah.com\www\rss.xml" output="#theXml#">

Open in new window

0
 
PhyloxAuthor Commented:
This is the validator I am using http://validator.w3.org/feed/
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
azadisaryevCommented:
ok, you still do have 2 duplicate guid values with jobid=19886 in your feed (one around line #368, another around line #407 - i say 'around' because in my test xml file i have already moved the <atom:link ..> tag to the top, as per the next paragraph below). the validator reports 4 duplicates because, iirc, it reports an error for both opening and closing <guid> tags.

you also need to move your <atom:link ...> node to the top of your xml file. place it just after the opening <channel> tag. this will solve the "Misplaced Item" error - all <item></item> nodes must be at the end of <channel>, and you had that <atom:link ...> tag as the last node in <channel> after the last <item></item> node...

also, in the <atom:link ...> tag you must make sure the HREF attribute actually points to the location of this .xml file - you must include the filename in the HREF attribute, not just domain name. thus you <atom:link ...> tag should look something like:
<atom:link href="http://blahblah.com/filename.xml" rel="self" type="application/rss+xml" />
where filename.xml is the actual name of this xml file.

Azadi
0
 
azadisaryevCommented:
PS: the opening <cfprocessingdirective> tag should go BEFORE <cfsavecontent> tag, and the closing tag should be AFTER </cfsavecontent> tag.

Azadi
0
 
azadisaryevCommented:
PPS: your whole xml generating code should look like this (see attched)

Azadi
<cfprocessingdirective suppresswhitespace="true">
<cfsetting enablecfoutputonly="yes">
<cfscript>
function stripHTML(str) {
 str = reReplace(str, "<.*?>","","all");
 //get partial html in front
 str = reReplace(str, "^.*?>","");
 //get partial html at end
 str = reReplace(str, "<.*$","");
 //replace html entities
 str = reReplace(str, "&[\w]*;", "", "all");
 return str;
}
</cfscript>
<cfsavecontent variable="theXML"><cfoutput><?xml version="1.0" encoding="ISO-8859-1" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
 <atom:link href="http://www.blahblah.com/rss.xml" rel="self" type="application/rss+xml" />
 <title>RSS</title>
 <link>http://www.blahblah.com</link>
 <description>Latest Postings</description>
 <language>en-us</language>
 <copyright>Copyright 2009 Blah Blah Online</copyright>
 <lastBuildDate>#dateformat(now(), "ddd, dd mmm yyyy")# #timeformat(now(), "HH:mm:ss")# GMT</lastBuildDate>
 <image>
 <title>Blah Blah RSS</title>
 <url>http://www.blahblah.com/logorss.jpg</url>
 <link>http://www.blahblah.com</link>
 </image>
</cfoutput>
<cfoutput query="Getjob">
 <item>
  <title><![CDATA[ #title# ]]></title>
  <pubDate>#dateformat(now(), "ddd, dd mmm yyyy")# #timeformat(now(), "HH:mm:ss")# GMT</pubDate>
  <description>#xmlformat(stripHTML(description))#</description>
  <guid isPermaLink="true">http://www.blahblah.com/career.cfm?jobid=#jobid#</guid>
 </item>
</cfoutput>
<cfoutput>
</channel>
</rss>
</cfoutput>
</cfsavecontent>
<cffile action="write" file="Z:\\Blah\www.blahblah.com\www\rss.xml" output="#trim(theXml)#">
</cfprocessingdirective>

Open in new window

0
 
PhyloxAuthor Commented:
Hi Azad, I've used your code and it fixed everything but the duplicate values.  I checked the XML and it looks like there are two duplicate postings with the same value.  I cannot figure out for the life of me what is causing two of them to show up for value 19886.  I checked all my other feeds that pulls in data from the database using the same query....None of them show two duplicate values for 19886.  
0
 
PhyloxAuthor Commented:
I figured it out, something was wrong with my sql query.  Thanks so much.  
0
 
PhyloxAuthor Commented:
Very detailed and to the point.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now