Creating rss feed with Coldfusion

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default Creating rss feed with Coldfusion

    Hi,

    I'm getting the following xml errorswhen I'm trying to do this, can anybody
    help?

    ----error----
    XML Parsing Error: xml processing instruction not at start of external entity
    Line Number 2, Column 114: SELECT * FROM news_articles ORDER BY
    article_id DESC; </cfquery><cfsavecontent VARIABLE="theXML"><cfoutput><?xml
    version="1.0" encoding="iso-8859-1"?><rss version="2.0">

    --------------------------------------------------------------------------------
    ---------------------------------^
    -----end error---




    Thanks in advance

    ----code attached----

    <cfsetting enablecfoutputonly="yes">
    <cfquery name="newsArticles" datasource="news" username="#dsn_username#"
    password="#dsn_password#">
    SELECT * FROM news_articles ORDER BY article_id DESC; </cfquery>
    <cfsavecontent VARIABLE="theXML">
    <cfoutput>
    <?xml version="1.0" encoding="iso-8859-1"?><rss version="2.0">
    <channel>
    <title></title>
    <link></link>
    <description></description>
    <copyright></copyright>
    </cfoutput>
    <cfloop FROM="1" TO="#newsArticles.recordcount#" index="i">
    <cfscript>

    body = replace(newsArticles.body[i],"<","&lt;","ALL");
    body = replace(body,">","&gt;","ALL");
    body = replace(body,"&","&amp;","ALL");
    body = replace(body,"","","ALL");
    date = dateformat(newsArticles.date_created[i], "ddd, dd mmm yyyy");
    author = replace(newsArticles.author[i],"<","&lt;","ALL");
    </cfscript>
    <cfoutput>
    <item>
    <TITLE>#newsArticles.heading#</TITLE>
    <description>#lcase(body)#</description>
    <LINK>
    http://www.halesowen.ac.uk/</link>
    <author>#author#</author>
    <pubDate>#date#</pubDate>
    <item>
    </cfoutput>
    </cfloop>
    <cfoutput> </channel> </rss> </cfoutput></cfsavecontent>
    <cfcontent TYPE="text/xml">
    <cfoutput>#thexml#</cfoutput>

    Mattastic Guest

  2. Similar Questions and Discussions

    1. Creating ColdFusion CMS
      I am working on designing a RIA for my school district. I update the main site while others update individual school web pages. I want to make a...
    2. Problem Creating Coldfusion Datasource
      Hello, I have installed MySQL 5.0.15 and Coldfusion MX 7 Developer Edition on my Mac Powerbook G4 running OS X 10.4.5. MySQL is working okay and...
    3. Creating an RSS feed
      Has anyone created an rss feed? I need help. My RSS feed validates at feedvalidator.org but will not display in Mozilla. currently the file name...
    4. ADVICE: Need sheet feed scanner for creating Word doc's w/Acrobat
      I need to scan about 1000 pages of mostly text, to be converted to Word documents and ultimately imported into InDesign. I have a flatbed scanner and...
    5. help with rss creating code creating an XML rss feed]
      When I run the following code I get the follwing error and cant really see the problem I am incxluding this file from another page thanks in...
  3. #2

    Default Re: Creating rss feed with Coldfusion

    How are you loading the XML into a variable? If that is happening then you must
    be reading the file with cffile? To read it as XML you will have to use cfhttp
    so that the CF App Server can render the page. Otherwise you are just reading
    in your template.

    Stressed_Simon Guest

  4. #3

    Default Re: Creating rss feed with Coldfusion

    Thanks for the reply.

    I see what you mean.

    I have got it working now so it writes to a seperate xml file.

    Is this the best way to do it?

    I could set up a scheduled task to write to the file every so often to keep it
    up to date?



    Mattastic Guest

  5. #4

    Default Re: Creating rss feed with Coldfusion

    The best way is to do as you suggested and write the xml file with a schedule. This way your data is kept up to date but you don't have to cope with serving dynamic data to aggregators.
    Stressed_Simon Guest

  6. #5

    Default Re: Creating rss feed with Coldfusion

    Make sure the following are on the same line:

    <cfoutput>
    <?xml version="1.0" encoding="iso-8859-1"?>

    like this:

    <cfoutput><?xml version="1.0" encoding="iso-8859-1"?>

    The XML tag MUST be the first thing in the page, no spaces or line
    breaks or anything else before it.

    [url]http://blog.hotpepper.ca/archives/2005/11/rss-and-coldfusion/[/url]

    kim.siever@gmail.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139