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

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>
Get complete source code from here

Source: techaspirant.com

VN:F [1.9.17_1161]
Rating: 4.0/10 (1 vote cast)
VN:F [1.9.17_1161]
Rating: +1 (from 1 vote)
Creating XML-RSS Feed Using PHP MYSQL, 4.0 out of 10 based on 1 rating

Related Posts

  • No Related Post
Related Posts with Thumbnails

About the Author

techremind

has written 42 stories on this site.

Write a Comment

Copyright © 2012 CoreTimer.com|System Admin’s Reference. All rights reserved.

Switch to our mobile site