<?

/*
RSS 092 to OPML : Kosso : 12 June 2006

# gnomedex_rss092_opml.pods (podcast.com source)
# For use as .php file


# Creates an OPML 1.0 feed from the RSS 0.92 feed provided by Chris Pirillo of Gnomedex.com
# This feed lists all the attendees and their website and RSS feeds - if available.

# Feel free to use this code anywhere! ;)
# Kosso


*/

// Here's Chris' RSS feed url...

$rssUrl "http://rpc.blogrolling.com/rss.php?r=01a2b5cd7c11e1a5f86e415f7258b15c";


// Use the great SimpleXML functions from PHP 5+
// See: http://uk.php.net/manual/en/ref.simplexml.php

$rss simplexml_load_file($rssUrl);


// grab the lastBuildDate
$lastBuild $rss->channel->lastBuildDate;


$outlines "";

// Let's flip through the RSS items ... (in 'channel')

foreach ($rss->channel->item as $item) {

    
$title =  $item->title;
    
$link =  $item->link;

    
// description tag appears to be used for the RSS feed url
    
$description $item->description;


    
// Some of the tags in the rss feed don't make sense.
    // I'll do a quick check to see if the link equals the 'description' (used for the rss feed url)    
    // It seems that those without a feed or link have been given a gnomedex.com url, but I'll leave that there for now.

    // So, lets build the rest of our OPML attributes for each entry in the RSS feed
    // We'll use type=link for the web urls  - OPML 2.0 may change this assumption

    // Also check for http:// as blogrolling seems to create some erroneous entries

    
if($link!=$description && strstr($description'http://')){

        
$attributes "type=\"rss\" htmlUrl=\"".$link."\" xmlUrl=\"".$description."\"";
    } else {
        
$attributes " type=\"link\" htmlUrl=\"".$link."\"";
    }

    
// Gobble them up....
    
$outlines .= "\t<outline text=\"".$item->title."\" ".$attributes." />\n";
}

    
// Build the OPML 1.0 header

    
$opmlOutput "<?xml version=\"1.0\"?>\n
                <opml version=\"1.0\">\n
                <head>\n
                <title>Gnomedex 6.0 Attendees - RSS092 to OPML by Kosso at podcast.com </title>\n
                <dateModified>"
.$lastBuild."</dateModified>\n
                <!-- source RSS 0.92 feed at "
.$rssUrl." -->\n
                </head>\n
                <body>\n"
;


    
// Concatenate the outline nodes

    
$opmlOutput .= $outlines;

    
// And round it off with the footer tags.

    
$opmlOutput .= "</body>\n</opml>";

    
// Set the PHP output format
    
header('Content-type: text/xml');

    
// ... and spit it out!!
    
echo $opmlOutput;

    
// Hurrah!!
    // Cheers!
    // Kosso
    // See you at in Seattle!
?>