Location: PHPKode > scripts > ReGet Parser > reget-parser/ReGetParser.class.php
<?php

class ReGetParser {

	var $parser;
	var $xml_file= "";
	var $files= array();
	
	var $error_id= 0;
	var $error_message= "OK";
	var $errors= 0;
	
	function ReGetParser ($XML_file) {
		$this->xml_file= $XML_file;
	
		$this->parser= xml_parser_create();
		xml_set_element_handler ($this->parser, array (&$this, "startElementHandler"), array (&$this, "endElementHandler"));
		xml_set_character_data_handler ($this->parser,  array (&$this, "cdataHandler"));
		
		if (file_exists($this->xml_file)) {
			@$xml_data= file_get_contents($this->xml_file);
	
			if ($xml_data) {
				xml_parse ($this->parser, $xml_data);
			}
			else {
				$this->error_id= 2;
				$this->error_message= "Cant read XML file\n";
				$this->errors= 1;
			}
		}
		else {
			$this->error_id= 1;
			$this->error_message= "XML file not found\n";
			$this->errors= 1;
		}
		
		xml_parser_free($this->parser);
	}

	function startElementHandler($parser, $name, $attribs){

		switch ($name) {
			case ("DOWNLOAD"):
				$index= count($this->files);

				$this->files[$index]= $attribs;
				break;
		}
	}

	function endElementHandler($parser, $name) {
		// Nothing
	}

	function cdataHandler($parser, $data) {
		// Nothing
	}

}

?>
Return current item: ReGet Parser