Reputation: 13394
I use SimplePie to parse RSS feeds in php. For pre-processing the result of SimplePie, I need to know if the the link is a permalink or not. The info is stored in this XML element:
<guid isPermaLink="false">FileNr123</guid>
If $items
is an instance of SimplePie objet that stands for one RSS feed item, I can use $item->get_permalink
to get the permalink. Unfortunately this returns the fileName/guid, even if isPermaLink="false"
So how can I access the isPermaLink
attribute of every feed item to post-process the SimplePie output?
Upvotes: 3
Views: 2291
Reputation: 13394
On option is to use the get_item_tags
method in order to walk trough the array and search for the first isPermaLink
:
$guid = $item->get_item_tags('','guid');
$arrIt = new RecursiveIteratorIterator(new RecursiveArrayIterator($guid[0]));
foreach ($arrIt as $sub) {
$subArray = $arrIt->getSubIterator();
if (isset($subArray['isPermaLink']) && $subArray['isPermaLink'] == "false")
{$isPermalink = false ;break;}
}
This works, but it's not satisfying, bacause some RSS provider sets isPermaLink
to false
even the link works correctly for a long time.
Upvotes: 2