X-Git-Url: http://git.dj3c1t.com/?a=blobdiff_plain;ds=sidebyside;f=web%2Flibs%2Fsxml.php;fp=web%2Flibs%2Fsxml.php;h=7d5bf20325aac2217a6eb673b567de5710046cbf;hb=29b6377f43bf4477e04b57069cf779ac1b913bdb;hp=78533f3944b438119bba9fadc6a223bfaae63307;hpb=a21fbfe1301f83b72d2815899ff334445b7830cf;p=mtweb diff --git a/web/libs/sxml.php b/web/libs/sxml.php index 78533f3..7d5bf20 100644 --- a/web/libs/sxml.php +++ b/web/libs/sxml.php @@ -16,8 +16,8 @@ */ -class sxml -{ + class sxml{ + var $parser; var $error_code; var $error_string; @@ -25,50 +25,45 @@ class sxml var $current_column; var $data; var $datas; - function parse($data) - { -// $this->parser = xml_parser_create('UTF-8'); + + function parse($data){ + // $this->parser = xml_parser_create('UTF-8'); + $this->data = array(); + $this->datas = array(); + $this->parser = xml_parser_create(); + xml_set_object($this->parser, $this); + xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1); + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); + xml_set_element_handler($this->parser, 'tag_open', 'tag_close'); + xml_set_character_data_handler($this->parser, 'cdata'); + if (!xml_parse($this->parser, $data)){ $this->data = array(); - $this->datas = array(); - $this->parser = xml_parser_create(); - xml_set_object($this->parser, $this); - xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1); - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); - xml_set_element_handler($this->parser, 'tag_open', 'tag_close'); - xml_set_character_data_handler($this->parser, 'cdata'); - if (!xml_parse($this->parser, $data)) - { - $this->data = array(); - $this->error_code = xml_get_error_code($this->parser); - $this->error_string = xml_error_string($this->error_code); - $this->current_line = xml_get_current_line_number($this->parser); - $this->current_column = xml_get_current_column_number($this->parser); - } - else - { - $this->data = $this->data['subs']; - } - xml_parser_free($this->parser); + $this->error_code = xml_get_error_code($this->parser); + $this->error_string = xml_error_string($this->error_code); + $this->current_line = xml_get_current_line_number($this->parser); + $this->current_column = xml_get_current_column_number($this->parser); + } + else{ + $this->data = $this->data['subs']; + } + xml_parser_free($this->parser); } - - function tag_open($parser, $tag, $attribs) - { - $this->datas[] = &$this->data; - $this->data = &$this->data['subs'][$tag][]; - if($attribs) $this->data['attrs'] = $attribs; - + + function tag_open($parser, $tag, $attribs){ + $this->datas[] = &$this->data; + $this->data = &$this->data['subs'][$tag][]; + if($attribs) $this->data['attrs'] = $attribs; } - - function cdata($parser, $cdata) - { - @$this->data['data'] .= $cdata; + + function cdata($parser, $cdata){ + @$this->data['data'] .= $cdata; } - - function tag_close($parser, $tag) - { - $this->data =& $this->datas[count($this->datas)-1]; - array_pop($this->datas); + + function tag_close($parser, $tag){ + $this->data =& $this->datas[count($this->datas)-1]; + array_pop($this->datas); } -} + + } ?> \ No newline at end of file