Google Alerts PHP RSS Feeds

Feb 2nd 2011

This is a simple script that will parse Google Alert feeds into manageable XHTML.


<?php


/* 

 * CREATED BY: JOHN ANDERSON
 * Feb 1, 2011
 * htt://www.variux.com
 */


$feed       =   file_get_contents('http://www.google.com/alerts/feeds/09402358563287942509/4984596073510297530');

$xml        =   simplexml_load_string($feed);

foreach(
$xml->entry as $k => $data){

    echo 
'<h2><a href="' $data->link->attributes()->href '" >' strip_tags($data->title) . '</a></h2>' "\n";
    echo 
'<h3>' date("F jS Y g:iA",strtotime($data->published)) . '</h3>' "\n";
    echo 
'<p>'  substr(strip_tags($data->content),0,100) . "...\n";

}

?>