PHP code example of athoshun / feed-parser

1. Go to this page and download the library: Download athoshun/feed-parser library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

athoshun / feed-parser example snippets




function print_rss($rss_xml)
{
    $dom = new DOMDocument("1.0", "UTF-8");
    $dom->loadXML($rss_xml);

    $rss = new AthosHun\FeedParser\RSSFeedType();
    $xml_feed = new AthosHun\FeedParser\XMLFeed($rss, $dom);

    print "Title: " . $xml_feed->getTitle() . "\n";
    print "URL: " . $xml_feed->getURL() . "\n\n";

    foreach ($xml_feed->getItems() as $key => $item) {
        $i = $key + 1;
        print " $i. Id: " . $item->getId() . "\n";
        print " $i. Title: " . $item->getTitle() . "\n";
        print " $i. URL: " . $item->getURL() . "\n";
        print " $i. Timestamp: "
              . date("Y-m-d H:i:s", $item->getTimestamp()) . "\n";
        print " $i. Body: " . $item->getBody() . "\n\n";
    }
}

print_rss(<<<RSS
<?xml version="1.0" encoding="UTF-8"