Showing posts with label parse xml. Show all posts
Showing posts with label parse xml. Show all posts
PHP RSS Feed Reader using Curl-PHP RSS parser
Posted by Raj
PHP RSS Feed Reader using Curl-PHP RSS parser
In this article,I will explain how to Read RSS feed in php.I have used PHP Curl library to parse RSS feeds with PHP.we can covert rss feed to content using PHP.
Please check below php rss reader example:
<?php
//Used cURL to get the RSS feed into a PHP string variable
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://example.php/rss.xml');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xml = curl_exec($ch);
curl_close($ch);
$return_data = new SimpleXmlElement($xml, LIBXML_NOCDATA);//I have used the
SimpleXML PHP functions to parse XML documents
$items = count($return_data->channel->item);
for($i=0; $i<$items; $i++)
{
$desc = $return_data->channel->item[$i]->title;
$desc = $return_data->channel->item[$i]->link;
echo $desc = $return_data->channel->item[$i]->description;
}
?>
In this article,I will explain how to Read RSS feed in php.I have used PHP Curl library to parse RSS feeds with PHP.we can covert rss feed to content using PHP.
Please check below php rss reader example:
<?php
//Used cURL to get the RSS feed into a PHP string variable
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'http://example.php/rss.xml');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$xml = curl_exec($ch);
curl_close($ch);
$return_data = new SimpleXmlElement($xml, LIBXML_NOCDATA);//I have used the
SimpleXML PHP functions to parse XML documents
$items = count($return_data->channel->item);
for($i=0; $i<$items; $i++)
{
$desc = $return_data->channel->item[$i]->title;
$desc = $return_data->channel->item[$i]->link;
echo $desc = $return_data->channel->item[$i]->description;
}
?>