我如何获得最后一个RSS提要的内容

问题描述

| 我有这个提要,我只需要解析最新的RSS提要。我基本上想知道我是否可以获取最新的信息...我有这段代码可以帮助解析所有RSS Feed,但是我如何获取最新的
$validCache = false;
if (file_exists(\'RSS_cache.txt\')) {
    $contents = file_get_contents(\'RSS_cache.txt\');
    $data = unserialize($contents);
    if (time() - $data[\'created\'] < 24 * 60 * 60) {
        $validCache = true;
        $Feed = $data[\'Feed\'];
    }
}

if (!$validCache) {
    $Feed = file_get_contents(\'http://someplace.com/Feed/\');
    $data = array (\'Feed\' => $Feed,\'time\' => time());
    file_put_contents(\'RSS_cache.txt\',serialize($data));
}
编辑:尝试
$xml = simplexml_load_file(\'http://blog.airdye.com/goodforwater/Feed/\');
print_r($xml->channel->item[0]);
但说明为空白
SimpleXMLElement Object
(
    [title] => one textile company gives away water filters and profits
    [link] => http://blog.airdye.com/goodforwater/2011/05/20/one-textile-company-gives-away-water-filters-and-profits/
    [comments] => http://blog.airdye.com/goodforwater/2011/05/20/one-textile-company-gives-away-water-filters-and-profits/#comments
    [pubDate] => Fri,20 May 2011 20:09:31 +0000
    [category] => Array
        (
            [0] => SimpleXMLElement Object
                (
                )

            [1] => SimpleXMLElement Object
                (
                )

            [2] => SimpleXMLElement Object
                (
                )

            [3] => SimpleXMLElement Object
                (
                )

            [4] => SimpleXMLElement Object
                (
                )

        )

    [guid] => http://blog.airdye.com/goodforwater/?p=2673
    [description] => SimpleXMLElement Object
        (
        )

)
    

解决方法

        答案已编辑:
<pre>
<?php

$xml = simplexml_load_file(\'http://wizardsoweb.com/feed\');
print_r($xml->channel->item[0]);
?>
</pre>
这是我正在阅读最新帖子的示例。