Source for file RssParser.php
Documentation is available at RssParser.php
// ----------------------------------------------------------------------------------
// Class: RSS/ATOM Parser
// ----------------------------------------------------------------------------------
* This class uses the MagpieRSS Parser by Kellan Elliott-McCrea <kellan@protest.net>. MagpieRSS is
* compatible with RSS 0.9 through RSS 1.0. Also parses RSS 1.0's modules, RSS 2.0, and Atom (with a few exceptions).
* Magpie is distributed under the GPL license. (http://magpierss.sourceforge.net/)
* @author Tobias Gauß <tobias.gauss@web.de>
* @version $Id: fsource_syntax__syntaxRssParser.php.html 443 2007-06-01 16:25:38Z cax $
* @param $url location of the document
if(substr($url,0,7)==
"http://"){
$this->type =
$rss->feed_type;
$version =
$rss->feed_version;
$nmsp =
"http://purl.org/rss/1.0/";
$nmsp =
"http://my.netscape.com/publish/formats/rss-spec-0.91.html#";
$nmsp =
"http://purl.org/rss/1.0/";
if($this->type ==
"Atom")
$nmsp =
"http://www.w3.org/2005/Atom";
if($this->type ==
"Atom")
$this->channel($model,$rss,$bn,$nmsp,"feed");
$this->channel($model,$rss,$bn,$nmsp,"channel");
$this->image($model,$rss,$bn,$nmsp);
$this->items($model,$rss,$bn,$nmsp);
$model->addNamespace("rdf","http://www.w3.org/1999/02/22-rdf-syntax-ns#");
$model->addNamespace($this->type,$nmsp);
* Parses the image if there is one.
* @param $model the model
* @param $rss the magpie parser object
* @param $bnOrg the node which represents the channel
function image(&$model,&$rss,&$bnOrg,&$nmsp){
if(count($rss->image)>
0){
if(isset
($rss->image['about'])){
$bn =
new Resource($rss->image['about']);
}else if(isset
($rss->image['url'])){
foreach($rss->image as $key =>
$value){
$this->dc($bn,$model,$value);
$this->sy($bn,$model,$value);
* Parses the rss items/ atom entries.
* @param $model the model
* @param $rss the magpie parser object
* @param $bnOrg the node which represents the channel
function items(&$model,&$rss,&$bnOrg,&$nmsp){
$model->add(new Statement($items,new Resource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),new Resource("http://www.w3.org/1999/02/22-rdf-syntax-ns#Seq")));
foreach($rss->items as $outerKey =>
$outerValue){
if(isset
($outerValue['about'])){
$bn =
new Resource($outerValue['about']);
}else if(isset
($outerValue['guid'])){
$bn =
new Resource($outerValue['guid']);
}else if(isset
($outerValue['id'])){
$bn =
new Blanknode("item".
$i);
$model->add(new Statement($items,new Resource("http://www.w3.org/1999/02/22-rdf-syntax-ns#_".
$i),$bn));
if($this->type ==
"Atom"){
$model->add(new Statement($bn,new Resource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),new Resource("http://www.w3.org/2005/Atomentry")));
$model->add(new Statement($bn,new Resource("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"),new Resource("http://purl.org/rss/1.0/item")));
foreach($outerValue as $key =>
$value){
$this->dc($bn,$model,$value);
$this->sy($bn,$model,$value);
* @param $model the model
* @param $dc Array which contains the dc objects
function dc(&$node,&$model,&$dc){
$model->addNamespace("dc","http://purl.org/dc/elements/1.1/");
foreach($dc as $key =>
$value){
* @param $model the model
* @param $sy Array which contains the sy objects
function sy(&$node,&$model,&$sy){
$model->addNamespace("sy","http://purl.org/rss/1.0/modules/syndication/");
foreach($sy as $key =>
$value){
$statement =
new Statement($node,new Resource("http://purl.org/rss/1.0/modules/syndication/".
$key), new Literal($value));
* Parses the rss channel/ atom feed.
* @param $model the model
* @param $rss the magpie parser object
* @param $node the node which represents the channel
function channel(&$model,&$rss,&$node,&$nmsp,$type){
$statement =
new Statement($node,new Resource('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'), new Resource($nmsp.
$type));
foreach($rss->channel as $key =>
$value){
$this->dc($node,$model,$value);
$this->sy($node,$model,$value);
Documentation generated on Fri, 1 Jun 2007 16:51:43 +0200 by phpDocumentor 1.3.2