Skip to content

Commit

Permalink
added rich feed parsing example
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdebril committed May 23, 2017
1 parent a54ca96 commit e9c89ed
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions examples/rich-feed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/*
* This file is part of the feed-io package.
*
* (c) Alexandre Debril <alex.debril@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

require __DIR__.DIRECTORY_SEPARATOR.'bootstrap.php';

$feedIo = \FeedIo\Factory::create()->getFeedIo();

$result = $feedIo->read('https://debril.org/feed/');

echo "feed title : {$result->getFeed()->getTitle()} \n ";

foreach ($result->getFeed() as $item) {
echo "item title : {$item->getTitle()} \n ";

foreach ($item->getAllElements() as $element) {
echo "element name : " . $element->getName() . PHP_EOL;

foreach( $element->getAllElements() as $subElement) {
echo "sub element name : " . $subElement->getName() . PHP_EOL;
echo "sub element value : " . $subElement->getValue() . PHP_EOL;
}
}

}

0 comments on commit e9c89ed

Please sign in to comment.