Tryag File Manager
Home
-
Turbo Force
Current Path :
/
home
/
cluster1
/
data
/
bu01
/
1121861
/
html
/
jlex
/
nahuatl
/
php4
/
Upload File :
New :
File
Dir
//home/cluster1/data/bu01/1121861/html/jlex/nahuatl/php4/changer_2.php4
<? class changer_2 { var $parser; var $out; var $data; var $cur_field; function changer_2() { $this->cur_field = 0; } function startHandler($xp,$element,$attribs) { $element = strtolower($element); if($element == "refgroup") { $this->cur_field = 0; } } function endHandler($xp,$element) { $element = strtolower($element); if($element != "refgroup") { if($element == "lxoa") { if($this->cur_field == 0) { fwrite($this->out,"\\$element $this->data\n"); } else { fwrite($this->out,"\\lxoa_alt $this->data\n"); } $this->cur_field++; } else { if($this->data != "") { fwrite($this->out,"\\$element $this->data\n"); } } } else { fwrite($this->out,"\n"); } $this->data = ""; } function cDataHandler($xp,$data) { $data = trim($data); if($data != "") { $data = ereg_replace("&","&",$data); $data = ereg_replace("<","<",$data); $data = ereg_replace(">",">",$data); $this->data .= $data; } } function change_lxoa($xml,$new_shoebox_name) { $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"); $in = fopen($xml,"r"); $this->out = fopen($new_shoebox_name,"w"); while($line = fgets($in)) { xml_parse($this->parser,$line,false); } } } $sc = new changer_2(); $sc->change_lxoa("ActiveNahuatl_2005_august_final.xml","fixed_lxoa.txt"); ?>