This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
In this article, you will learn how to read an RSS feed in PHP. RSS stands for Really Simple Syndication and it is a web feed that allows subscribers to get updates from multiple websites on a single page.
Read RSS Feed
In order to read an RSS feed, you can use the file_get_contents()
method andSimpleXMLElement()
method.
$content = file_get_contents("https://feeds.feedburner.com/phpclassesblog-xml");
// Instantiate XML element
$a = new SimpleXMLElement($content);
echo "<ul>";
foreach($a->channel->item as $entry) {
echo "<li><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></li>";
}
echo "</ul>";
Note: The file_get_contents()
method functions by reading the content of a file into a string. The SimpleXMLElement()
method functions by representing an XML element.
The post How to Read RSS Feed in PHP appeared first on CodeSource.io.
This content originally appeared on CodeSource.io and was authored by Ariessa Norramli
Ariessa Norramli | Sciencx (2021-03-06T05:03:22+00:00) How to Read RSS Feed in PHP. Retrieved from https://www.scien.cx/2021/03/06/how-to-read-rss-feed-in-php/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.