6 Replies Latest reply on Mar 21, 2007 7:29 AM by Newsgroup_User

    Read a RSS feed into my html page

    SebulbaSe
      Hi
      Just need some advice.
      I have a rssfeed that is in swedish so i get some specialcharacters in it like åäöÅÄÖ.

      I use this code
      <cfhttp url=" http://blogg.fotbolldirekt.com/xml_consult.php" method="GET" resolveurl="no" charset="utf-8" ></cfhttp>
      <cfset fdblogg_xml=XMLParse(cfhttp.FileContent)>

      to call for the rss feed.

      then i use this code to output the result

      <cfloop index="x" from="1" to="3">
      <tr><td colspan="2"><a href="#fdblogg_xml.rss.item[x].link.xmlText#" class="NewsName">#fdblogg_xml.rss.item[x].title.xmlText#</a></td></tr>
      <tr><td valign="top"><img src="#fdblogg_xml.rss.item[x].urlthumb.xmlText#" border="0"></td><td valign="top" class="Text">#Mid(fdblogg_xml.rss.item[x].description.xmlText,1,80)#...</td></tr>
      </cfloop>

      Can anyone give me a hint, need to figure out how to get the specialcharacters to show correct on the webpage.

      Thanks
      Magnus
        • 1. Re: Read a RSS feed into my html page
          maxell Level 1
          Try adding this: <cfprocessingdirective pageEncoding="utf-8"> to the template.
          • 2. Re: Read a RSS feed into my html page
            SebulbaSe Level 1
            Hi again

            And thanks but that didn't do the trick.

            Any other suggestions?
            • 3. Re: Read a RSS feed into my html page
              Level 7
              Put the processing directive at the top of the page.

              Use the <cfsavecontent tag to set the encoding.

              Put encoding code into metatags in the <head> of the document.

              And I usually put in the <cfencoding...> tags in for forms and urls just
              in case.

              Do all the above all the time when working with encoding. And don't
              forget any other layers: databases, xml documents, ect. They must all
              agree on and use a consistent character set to prevent unpleasant behavior.

              • 4. Read a RSS feed into my html page
                SebulbaSe Level 1
                Im sorry but i still cant make it work.

                Here is my complete page in code...

                <cfprocessingdirective pageEncoding="utf-8">
                <html>
                <head>
                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <title>Test RSS-feed</title>
                <cfhttp url=" http://blogg.fotbolldirekt.com/xml_consult.php" method="GET" resolveurl="no" charset="utf-8"></cfhttp>
                <cfset fdblogg_xml=XMLParse(cfhttp.FileContent)>
                </head>

                <body>
                <cfoutput>
                <table width="185">
                <tr><td colspan="2" bgcolor="66CCFF"><b>FDs Bloggtips</b></td></tr>
                <cfloop index="x" from="1" to="3">
                <tr><td colspan="2"><a href="#fdblogg_xml.rss.item[x].link.xmlText#" class="NewsName">#fdblogg_xml.rss.item[x].title.xmlText#</a></td></tr>
                <tr><td valign="top"><img src="#fdblogg_xml.rss.item[x].urlthumb.xmlText#" border="0"></td><td valign="top" class="Text">#Mid(fdblogg_xml.rss.item[x].description.xmlText,1,80)#...</td></tr>
                </cfloop>
                </table>
                </cfoutput>
                </body>
                </html>

                If it works for someone else then i can guess i have some config to do on the server.

                /Magnus
                • 5. Re: Read a RSS feed into my html page
                  Level 7
                  i just tested your code and it worked absolutely fine... all Swedish
                  chars showed properly...

                  what's the page encoding setting in the browser you are viewing your
                  page with? make sure it is Unicode (UTF-8), too.
                  (I.e. in Firefox go to menu View -> Character Encoding -> select Unicode)
                  --

                  Azadi Saryev
                  Sabai-dee.com
                  http://www.sabai-dee.com
                  • 6. Re: Read a RSS feed into my html page
                    Level 7
                    The one thing I would add is a <cfcontent...> tag.

                    <cfprocessingdirective pageEncoding="utf-8">
                    <cfcontent type="text/html; charset=utf-8" reset="yes">
                    <head>
                    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />