Tryag File Manager
Home
-
Turbo Force
Current Path :
/
home
/
cluster1
/
data
/
bu01
/
1121861
/
html
/
old_jlex_versions
/
beta
/
2005-08-04 php4
/
Upload File :
New :
File
Dir
/home/cluster1/data/bu01/1121861/html/old_jlex_versions/beta/2005-08-04 php4/char_classes_parser.php4
<? /** * TESTED: 10/20/04 : 2:40 pm : working properly */ 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 get_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; } } ?>