7 http://www.shop24-7.info/32-0-simplexml-alternative-php4.html
12 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
13 dans la fonction parse($data) pour la prise en compte de la casse
16 if($attribs) $this->data['attrs'] = $attribs;
17 dans la fonction tag_open pour la prise en compte des attributs
31 function parse($data){
32 // $this->parser = xml_parser_create('UTF-8');
33 $this->data = array();
34 $this->datas = array();
35 $this->parser = xml_parser_create();
36 xml_set_object($this->parser, $this);
37 xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1);
38 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
39 xml_set_element_handler($this->parser, 'tag_open', 'tag_close');
40 xml_set_character_data_handler($this->parser, 'cdata');
41 if (!xml_parse($this->parser, $data)){
42 $this->data = array();
43 $this->error_code = xml_get_error_code($this->parser);
44 $this->error_string = xml_error_string($this->error_code);
45 $this->current_line = xml_get_current_line_number($this->parser);
46 $this->current_column = xml_get_current_column_number($this->parser);
49 $this->data = $this->data['subs'];
51 xml_parser_free($this->parser);
54 function tag_open($parser, $tag, $attribs){
55 $this->datas[] = &$this->data;
56 $this->data = &$this->data['subs'][$tag][];
57 if($attribs) $this->data['attrs'] = $attribs;
60 function cdata($parser, $cdata){
61 @$this->data['data'] .= $cdata;
64 function tag_close($parser, $tag){
65 $this->data =& $this->datas[count($this->datas)-1];
66 array_pop($this->datas);