FLY TO THE ZENITH OF SUCCESS

Arun Raj.R (Software Engineer)

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>
XML.com
<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>
Normalizing XML, Part 2
<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>
SVG’s Past and Promising Future
<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

Symfony 1.4 Doctrine Pagination made simple My inbox Giving a headache appearence-Nowadays I am very busy

Comments

Unregistered user Tuesday, August 3, 2010 3:36:24 PM

Анонімний writes: Some time before, I really needed to buy a building for my corporation but I did not earn enough cash and couldn't purchase something. Thank goodness my dude adviced to try to take the mortgage loans from banks. So, I did that and was happy with my auto loan.

Write a comment

New comments have been disabled for this post.

May 2012
M T W T F S S
April 2012June 2012
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