<?php

    
// Get the RSS feed generated by Yahoo Pipes (The pipe takes in a single get variable 'q' and then performs are Yahoo Search on BBC News feeds for the keywords passed to it.)
    
    
$data = @file_get_contents('http://pipes.yahoo.com/pipes/pipe.run?_id=diL2bsy_3RG2lHGzPxJ3AQ&_render=rss&q='.urlencode($_GET['q']));
    
    
// Create a new XML object from the Yahoo Pipes Feed.
    
    
if($data$xml = new simpleXMLElement($data); else $err 'Unable to Retrieve BBC News Feed';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title><?=$_GET['q']?> - BBC News RSS Feed</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" href="style_box.css" type="text/css" />
</head>
<body>
    <div id="wrapper">
        <h1><?=$_GET['q']?> - BBC News RSS Feed</h1>
        <?
            
if($data) {
                
// For each of the <item>'s within the RSS feed, echo out some XHTML containing some of the child values of that item.
                
                
foreach($xml->channel->item as $item) {
                    echo 
'
                    <div class="news">
                        <div>
                            <a href="'
.$item->link.'" target="_blank">'.$item->title.'</a>
                            <p>'
.$item->description.'</p>
                        </div>
                    </div>
                    '
;
                }
            } else {
                echo 
$err;
            }
        
?>
    </div>
</body>
</html>