简体   繁体   English

输出RSS feed为html?

[英]Output RSS feed as html?

有没有免费的php / javascript库,这有助于将RSS源显示为html?

In my Opinion Simplepie is one of the Best RSS parsers. 在我的意见中, Simplepie是最好的RSS解析器之一。

Here is an example: 这是一个例子:

require_once('simplepie.inc');
$feed = new SimplePie();
$feed->set_feed_url('http://simplepie.org/blog/feed/');
$feed->init();
$feed->handle_content_type();


    <?php foreach ($feed->get_items(0, 5) as $item): ?>

        <div class="item">
            <h2 class="title"><a href="<?php echo $item->get_permalink(); ?>"><?php echo $item->get_title(); ?></a></h2>
            <?php echo $item->get_description(); ?>
            <p><small>Posted on <?php echo $item->get_date('j F Y | g:i a'); ?></small></p>
        </div>

    <?php endforeach; ?>

Maybe SimplePie might help, here -- quoting its FAQ , it's : 也许SimplePie可能会有帮助,在这里 - 引用它的FAQ ,它是:

  • A code library, written in PHP, intended to make it ridiculously easy for people to manage RSS and Atom feeds. 一个用PHP编写的代码库,旨在让人们可以轻松地管理RSS和Atom提要。
  • An easy to use API that handles all of the dirty work when it comes to fetching, caching, parsing, normalizing data structures between RSS and Atom formats, handling character encoding translation, and sanitizing the resulting data. 一个易于使用的API,可处理所有脏工作,包括获取,缓存,解析,规范RSS和Atom格式之间的数据结构,处理字符编码转换以及清理结果数据。

Of couse, it will not do everything for you -- but it might help you get started. 当然,它不会为你做任何事 - 但它可能会帮助你开始。


Other solutions include, for instance, Zend_Feed_Reader or MagpieRSS . 其他解决方案包括,例如, Zend_Feed_Reader的magpierss

Try Magpie RSS . 试试Magpie RSS It can parse RSS feeds to arrays which you can easily iterate through and build your HTML. 它可以将RSS提要解析为数组,您可以轻松地迭代并构建HTML。

它实际上不是一个库,但我肯定会建议你使用XSL / XSLT

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM