class easy_parser{
var $old_element = "";
var $attribute = array();
var $dado = "";
var $array_element = array();
var $array_attribute_value = array();
var $array_attributes = array();
var $array_nodes = array();
var $current_element = "";
var $array_texto = array();
var $get_err = "";
var $texto = "";
function getpart($texto,$string,$reset=TRUE,$position=0)
{
static $p0=0;
$p0 += $position;
if($reset){
$p0 = 0;
}
$get = "";
$string = trim($string);
if(strpos($texto,"<$string>",$p0) >=0)
{
$p1 = strpos($texto,"<$string>",$p0);
$p2 = strpos($texto,"$string>",$p0);
$len = strlen("<$string>");
$get = substr($texto,($p1 + $len),($p2 - $p1 - $len));
$p0 = $p2+$len;
}
return $get;
}
function getrpart($texto,$string)
{
$get = "";
$string = trim($string);
if(strrpos($texto,"<$string>") >=0)
{
$p1 = strrpos($texto,"<$string>");
$texto2 = substr($texto,0,$p1);
$p2 = strrpos($texto2,"$string>");
$len = strlen("<$string>");
$get = substr($texto2,$p2);
}
return $get;
}
function parser($document,$is_file=TRUE){
$result = TRUE;
$parser = xml_parser_create('ISO-8859-1');
xml_set_object($parser,$this);
xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING, 0);
xml_set_element_handler($parser,"start_element","end_element");
xml_set_character_data_handler($parser,"character_data");
if($is_file){
if(file_exists($document)){
$xml_file = fopen($document,"r");
$data = "";
$ind = 0;
while (!feof($xml_file)) {
$data = fgets($xml_file,256);
if(ereg("","",$arrai[3]);
$arrai[3] = trim(str_replace("\"","",$arrai[3]));
if(file_exists($arrai[3])){
$fp = fopen($arrai[3],"r");
while(!feof($fp)){
$ext_val[$ind] .= fgets($fp,1024);
}
fclose($fp);
$ext_key[$ind] = trim($arrai[1]);
++$ind;
}
}
$this->texto .= $data;
}
fclose($xml_file);
}else{
print "The file: $document not found.