server-php-xml-class-path-parser-class-path-parser.php / php
<? //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
// Title : Class Path_parser // Version : 1.0 // Author : Luis Argerich (lrargerich@yahoo.com) // Last modification date : 06-24-2002 // Description : //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
// History: // 06-24-2002 : First version of this class. //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
// To-Dos: // //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
// How to use it: // Read the documentation in path_parser.html //#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
#
###
if(defined("_class_path_parser_is_included")) { // do nothing since the class is already included } else { define("_class_path_parser_is_included",1); // This is a class to parse XML files and call user functions // when specific elements (paths) are observed by the parser. class Path_parser { var context=Array(); var error; var this->error; } function Path_parser() { this->paths=Array(); this->parser,&this->parser, XML_OPTION_CASE_FOLDING, false); xml_set_element_handler(this->parser,"_data"); } function parse_file(fp = fopen(this->error="Cannot open data = fread(this->parser, fp))) { this->parser))." at line ".xml_get_current_line_number(this->parser); return true; } function parse(is_final) { this->parser,is_final); if (this->parser); } if(!this->error="XML error: ".xml_error_string(xml_get_error_code(this->parser); } return path,this->paths[handler_name; path]["depth"]=-1; } function _startElement(name,// Add the element to the context names=explode('^',names)>1) { names[1]; names[0]; } else { names[0]; } array_push(name); this->context); path; //print("Actual path: <br/>\n"); // Check all opened paths and update them foreach(array_keys(this->paths) as this->paths[this->paths[this->paths[name; foreach(atk => this->paths[atk.'="'.this->paths[// If the context path matches some UNMATCHED path then init element data if(in_array(path,array_keys(//print("Match!<br/>\n"); if(this->paths[this->paths[this->paths[this->paths[name; path]["name"]=this->paths[attribs; foreach(atk => this->paths[atk.'="'.this->paths[parser,// Decrement element depth array_pop(this->context); this->context); path; //print("Actual path: <br/>\n"); foreach(array_keys(this->paths) as this->paths[this->paths[this->paths[name.'>'; } if(pathk]["depth"]==0) { //print("Reportar: <br/>\n"); //print_r(this->paths[ this->paths[this->paths[this->paths[this->paths[this->paths[parser,this->paths) as this->paths[this->paths[data; } } } } } ?>
(C) Æliens 20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.