In this post i have explain about how Generate RSS Feed with PHP. Here i am using feed burner rss xml file to get the content because most of the users, blogger they are updating blog information in feed burner. Use below code add your website feeds information.
About RSS
RSS stands for Really Simple Syndication. It will allows you to syndicate your site content. Rss generally getting the website information in XML file. it allows personalized views for different sites.
Many users will check your website that time consuming make delay of website. rss they can check your website it will make faster then your website.
Basic structure of Rss feed
<?xml version='1.0' encoding='UTF-8'?> <rss version='2.0'> <channel> <title>Website Title </title> <link>Website URL</link> <description>Website description</description> <language>en-us</language> <item> <title>Title</title> <link> URL </link> <description>description </description> </item> </channel> </rss>
Code
Get the content in rss feed url via
<?php $xml = file_get_contents("http://feeds.feedburner.com/Mostlikers"); $obj = new SimpleXMLElement($xml); $arr = json_decode(json_encode($obj), TRUE); $arrs = $arr['channel']['item']; $i="0"; $j="0"; ?> <?php foreach ($arrs as $key => $rss) { ?> <div> <a href="<?=$rss['link']; ?>"><h3><?=$rss['title']; ?></h3></a> <p><?=substr($rss['description'],0,400); ?>...</p> </div> <hr> <?php } ?>
Thank you for visiting. if have any queries write comments below.
- Marcel Proust
No comments:
Post a Comment