Tryag File Manager
Home
-
Turbo Force
Current Path :
/
home
/
cluster1
/
data
/
bu01
/
1121861
/
jlex
/
php4
/
Upload File :
New :
File
Dir
//home/cluster1/data/bu01/1121861/jlex/php4/char_classes_parser.php4
<? class char_classes_parser { var $parser; var $name; var $char_classes; var $data; function char_classes_parser() { $this->parser = xml_parser_create(); xml_set_object($this->parser, $this); xml_set_element_handler($this->parser, "startHandler", "endHandler"); xml_set_character_data_handler($this->parser, "cDataHandler"); $this->name = ""; $this->char_classes = array(); $this->data = ""; } function load_user_char_classes($user_char_classes) { $char_classes = array(); foreach($user_char_classes as $char_class) { $char_class = trim($char_class); if($char_class != "") { $vals = explode(" = ",$char_class); $name = $vals[0]; $symbols = $vals[1]; $char_classes[$name] = $symbols; } } return $char_classes; } function get_xml_char_classes($xml) { if(file_exists($xml)) { $in = fopen($xml,"r"); while($line = fgets($in)) { $xml = ereg_replace("&", "&",$line); $xml = ereg_replace("<", "<",$xml); $xml = ereg_replace(">", ">",$xml); xml_parse($this->parser,$line,false); } } return $this->char_classes; } function startHandler($xp, $element, $attribs) { //$element = strtolower($element); } function endHandler($xp, $element) { $element = strtolower($element); if($element == "name") { $this->name = $this->data; } else if($element == "value") { $this->char_classes[$this->name] = $this->data; $this->name = ""; } $this->data = ""; } function cDataHandler($xp, $data) { if(trim($data) != "") $this->data .= $data; } } ?>