caching/parsing XML with SimpleXML

Source code


<?php include('./.config.php');
require(
'Cache/Lite/Output.php');
$id 'yahoo.oddlyenough.simpleXML';

$options = array(
    
'cacheDir' => './cache/',
    
'lifeTime' => 3600    // 1 hour
);
$cache = new Cache_Lite_Output($options);
10 
11 if (
strcasecmp($_SERVER['QUERY_STRING'],'remove')==0) {
12     
$cache->remove($id)    ;
13     exit(
"cache purged");
14 }
15 
16 if (!(
$cache->start($id))) {
17  
18     include(
'./.fetch_xml_with_socket.php5');
19     
$rss simplexml_load_string(fetchRss("rss.news.yahoo.com","/rss/oddlyenough"));
20 
21     foreach (
$rss->channel->item as $item) {
22 
23         
printf('<p><strong><a href="%s">%s</a></strong><br />%s</p>',
24         
$item->link,
25         
$item->title,
26         
$item->description);
27 
28     }
29 
30     
$cache->end(); // the buffered output is now stored into a cache file
31     
echo "<p>......used fresh data.........</p>";
32 
33 } else {
34     
35     echo 
"<p>.... and I got it from the cache, how cool is that? (-:</p>    " ;
36 }
37 include(
'./.footer.php')?>

Output


Warning: require(Cache/Lite/Output.php) [function.require]: failed to open stream: No such file or directory in /home/davidmintz/www/davidmintz.org/php_course/examples/10/simpleXML_rss_cached.php5 on line 2

Fatal error: require() [function.require]: Failed opening required 'Cache/Lite/Output.php' (include_path='/usr/home/dmintz/inc/pear:.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/davidmintz/www/davidmintz.org/php_course/examples/10/simpleXML_rss_cached.php5 on line 2