php - 使用 Zend_Feed 在 Php 中通过 url 获取 Rss 版本

标签 php zend-framework rss zend-feed

我使用 Zend Framework 读取 RSS 提要就像使用提要的 URL 实例化 Zend_Feed_Rss 对象一样简单:

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

该方法不存在

echo $feed->version();

如何获取 Rss 的版本,例如 2.0 或 0.92 ?

最佳答案

这当然不明显!

$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');

此示例适用于 RSS 2.0

您可能需要对原子等进行其他检查,但您现在可以了解如何访问根节点。

关于php - 使用 Zend_Feed 在 Php 中通过 url 获取 Rss 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1028947/

相关文章:

php - 当通过 iframe 加载网站时,网站将识别哪个 IP 地址?

php - 单元格宽度 = 文本宽度 FPDF

python - Flask + feedparser RSS 阅读器加载时间过长(15 秒)。我怎样才能减少这个时间?

php - 在 Laravel 中将依赖参数传递给 App::make() 或 App::makeWith()

php - 在mysql中通过什么方式创建这个库存

PHP 包含() : File size & performance

file - zend框架多输入文件上传

zend-framework - Zend Framework - 模块中的模块?

php - 无法将 RSS Feed 添加到 PHP 网站

rss - 在 MVC4/WebAPI 中创建 RSS 提要