Creating XML-RSS Feed Using PHP MYSQL

I have been working to create crowler friendly rss feed for our website. I think it is very easy to build . But when i started coding it i got so many problems with xml and special charcters. I tried program for replacing special characters. But it wont work. Finally i used utf8_encode. It worked

$h=utf8_encode(clean_url($result[‘name’]));
$d=utf8_encode(clean_url($result[‘discription’]));

I have attached PHP Source code for XML Generator

feed.php

Right click on the above link and save target as …

Below function is used to clean all extra characters in the content.

function clean_url($text)
{
$text=strtolower($text);
$code_entities_match = array(‘>>’,’–’,’�’,’–’,’&’,’“’,’”’,’–’,’’’,’-‘,’–‘,'”‘,’!’,’@’,’#’,’$’,’%’,’^’,’&’,’*’,'(‘,’)’,’_’,’+’,'{‘,’}’,’|’,’:’,'”‘,'< ‘,’>’,’?’,'[‘,’]’,’\\’,’;’,”‘”,’,’,’.’,’/’,’*’,’+’,’~’,’`’,’=’,’-‘,’ï’,’–’,”‘”,’O’);

return str_replace($code_entities_match,”, $text);
}

To make an rss feed you need title, description and link

Sample RSS FEED format

<rss version=”0.91″>
  <channel>
    <title>XML.com</title>
    <link>http://www.xml.com/</link>
    <description>XML.com features a rich mix of information and services for the XML community.</description>
    <language>en-us</language>
       <item>
            <title>Normalizing XML, Part 2</title>
            <link>http://www.xml.com/pub/a/2002/12/04/normalizing.html</link>
             <description>In this second and final look at applying relational normalization techniques to W3C XML Schema data modeling, Will Provost discusses when not to normalize, the scope of uniqueness and the fourth and fifth normal forms.</description>
       </item>

    <item>
      <title>SVG’s Past and Promising Future</title>
          <link>http://www.xml.com/pub/a/2002/12/04/svg.html</link>
           <description>In this month’s SVG column, Antoine Quint looks back at SVG’s journey through 2002 and looks forward to 2003.</description>
    </item>
  </channel>
</rss>

also go through the source code attached

About

me : yeay its me arun

Tagged with: , , , , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.