parser = xml_parser_create();
xml_set_object ( $this->parser, $this );
xml_set_element_handler ( $this->parser, 'tagStart', 'tagEnd' );
xml_set_character_data_handler ( $this->parser, 'tagContent' );
// Parst die GN-XML
xml_parse ( $this->parser, implode("",file("http://services.mac-newsticker.de/rss/topnews")));
}
function tagStart ( $parser, $tagName, $attributes = NULL )
{
if ($tagName == "")
return;
$this->tag = strtolower($tagName);
switch($this->tag)
{
case "item":
$this->item_open = true;
break;
}
}
function tagEnd ( $parser, $tagName )
{
if ($tagName == "")
return;
$this->tag = NULL;
switch(strtolower($tagName))
{
case "item":
$this->item_open = false;
$this->item_counter++;
break;
}
}
function tagContent ( $parser, $content )
{
if ($this->item_open == false)
return;
switch($this->tag)
{
case "title":
$this->item[$this->item_counter][$this->tag] .= $content;
break;
case "link":
$this->item[$this->item_counter][$this->tag] .= $content;
break;
case "guid":
$this->item[$this->item_counter][$this->tag] .= $content;
break;
}
}
}
// Laed die TopNews von mac-newsticker.de
$rss_news = new pnTopNews();
// Zeigt $n news an.
$n = 10;
for($i=0;$i<$n;$i++)
{
if (!isset($rss_news->item[$i]))
break;
// setzt die aktuelle News
$current_news = $rss_news->item[$i];
// Zeigt die aktuelle News an.
echo ''.htmlentities(utf8_decode($current_news['title'])).'
';
}
?>