<?
  $GLOBALS['titletag'] = false;
  $GLOBALS['linktag']  = false;
  $GLOBALS['descriptiontag'] = false;

  $GLOBALS['thetitletxt'] = null;
  $GLOBALS['thelinktxt'] = null;
  $GLOBALS['thedesctxt'] = null;
 
  function startTag( $parser, $tagName, $attrs ) {
     switch( $tagName ) {
	
      case 'TITLE':
        $GLOBALS['titletag'] = true;
        break;
      case 'LINK':
        $GLOBALS['linktag'] = true;
        break;
      case 'DESCRIPTION':
        $GLOBALS['descriptiontag'] = true;
        break;
    }
  }
 
 function endTag( $parser, $tagName ) {
     switch( $tagName ) {
	
      case 'TITLE':
        echo "<p><b>" . $GLOBALS['thetitletxt'] . "</b><br/>";
        $GLOBALS['titletag'] = false;
        $GLOBALS['thetitletxt'] = "";
        break;
      case 'LINK':
        echo "Link: <a href=\"". $GLOBALS['thelinktxt'] . "\">" . $GLOBALS['thelinktxt'] . "</a><br/>";
        $GLOBALS['linktag'] = false;
        $GLOBALS['thelinktxt'] = "";
        break;
      case 'DESCRIPTION':
        echo "Desc: " . $GLOBALS['thedesctxt'] . "</p>";
        $GLOBALS['descriptiontag'] = false;
        $GLOBALS['thedesctxt'] = "";
        break;
    }
  
  }
   function txtTag( $parser, $text ) {
       if( $GLOBALS['titletag'] == true ) {
        $GLOBALS['thetitletxt'] .= htmlspecialchars( trim($text) );
	
    } else if( $GLOBALS['linktag'] == true ) {
        $GLOBALS['thelinktxt']  .= trim( $text );
    } else if( $GLOBALS['descriptiontag'] == true ) {
        $GLOBALS['thedesctxt'] .= htmlspecialchars( trim( $text ) );
    }
  }
  
  
 function parsefile($RSSfile){
  // Create an xml parser
  $xmlParser = xml_parser_create();
  
  // Set up element handler
  xml_set_element_handler( $xmlParser, "startTag", "endTag" );
   
  // Set up character handler
  xml_set_character_data_handler( $xmlParser, "TxtTag" );
  
  // Open connection to RSS XML file for parsing.
  $fp = fopen($RSSfile,"r" )
    or die( "Cannot read RSS data file." );
    
  // Parse XML data from RSS file.
  while( $data = fread( $fp, 4096 ) ) {
 // echo "<marquee behavior=\"scroll\" direction=\"up\" scrollamount=\"2\" bgcolor=\"#FFCCFF\" loop=\"2\">";
    xml_parse( $xmlParser, $data, feof( $fp ) );
  }
   
  // Close file open handler
  fclose( $fp );
  
  // Free xml parser from memory
  xml_parser_free( $xmlParser );
  }
  ?>