6 Replies Latest reply on Feb 23, 2007 10:44 PM by Newsgroup_User

    RSS

    kt03 Level 1
      Hi,

      I never had done RSS Feed (XML file) before but I now I have to do it. I have the blog site and they want me to put last 10 blog entries output to RSS feed but I never had done it before so I don’t know where I begin to start with.

      thanks
        • 1. Re: RSS
          insuractive Level 3
          A quick google search for "Coldfusion RSS" turned up a slew of articles, including this one:

          http://www.webpronews.com/topnews/2004/04/05/creating-your-very-own-rss-xml-feeds-with-col dfusion-mx

          Basically, you are going to create a coldfusion page that generates the RSS xml file either on a regular basis or whenever an update is made (your choice), after that its just a matter of supplying the feed URL to your users.
          • 2. Re: RSS
            kt03 Level 1
            I have the blog entry form where end-user can submit the blog. When they hit the submit button for adding blog, I take these info and insert into the database and also write the xml file. I look at several examples from the web site and I try to do the same thing but keep getting an error. Please tell me what I did wrong here.

            Here the error I got:
            ====
            The XML page cannot be displayed
            Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


            --------------------------------------------------------------------------------

            Invalid at the top level of the document. Error processing resource 'file:///S:/scripts/rss/blog.xml'. Line 1, Position 1

            theXML
            ^

            ============
            Below is the code:
            ========================================
            • 3. Re: RSS
              Abinidi Level 1
              Use CFMXL to create the file. It will do better for formatting. And use CDATA also to validate correctly.
              • 4. Re: RSS
                kt03 Level 1
                My code now is working fine but it is not working with the way I want. My query returned three records and the xml file should display three different records but it was display the same record for three times. What did I have wrong here?

                Thanks
                • 5. Re: RSS
                  maxell
                  You should be using cfxml instead of cfsavecontent. Your created a loop for the length of your result set but you didn't index anything. If your not going to use the query attribute of cfloop you need to index the variables: #author[ctr]# .
                  • 6. Re: RSS
                    Level 7
                    kt03 wrote:

                    > <cfloop from="1" to = "#numberOfFeedItems#" index="ctr">
                    >
                    > <!--- Then output the fields for each item --->
                    > <cfoutput>
                    > <item>
                    > <title>#author#</title>
                    > <link>rss.cfm</link>
                    > <description>#body#</description>
                    > </item>
                    > </cfoutput>
                    > </cfloop>

                    change the above to:

                    <cfoutput query="getblog">
                    <item>
                    <title>#author#</title>
                    <link>rss.cfm</link>
                    <description>#body#</description>
                    </item>
                    </cfoutput>

                    Explanation:
                    your cfloop + cfoutput construct is wrong:
                    use just <cfoutput query="getblog"> instead of <cfloop ...><cfoutput>;
                    since your query already pulls only 3 top records only those will be
                    cfoutput'ed - no need to loop through anything;
                    alternatively, you can pull ALL records with your query (drop the TOP
                    #NumberOfFeedItems#) and then use <cfoutput query="getblog" startrow="1"
                    maxrows="#NumberOfFeedItems#">

                    --
                    Azadi Saryev
                    Sabai-dee.com
                    Vientiane, Laos
                    http://www.sabai-dee.com