Kevin Campion
Kevin Campion

Reputation: 2339

Get Rss version by url in Php with Zend_Feed

I use Zend Framework to read an RSS feed is as simple as instantiating a Zend_Feed_Rss object with the URL of the feed :

$feed = new Zend_Feed_Rss('http://rss.exemple.com/feed');
echo $feed->title();

This method doesn't exists

echo $feed->version();

How I can get the version of Rss, like 2.0 or 0.92 ?

Upvotes: 2

Views: 366

Answers (1)

David Snabel-Caunt
David Snabel-Caunt

Reputation: 58361

It's certainly not obvious!

$feed = new Zend_Feed_Rss('http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/uk/rss.xml');

$dom = $feed->getDOM();

$version = $dom->ownerDocument->documentElement->getAttribute('version');

This example works for RSS 2.0

You may need other checks for atom etc, but you can see how to access the root node now.

Upvotes: 3

Related Questions