<?php function xml_load_file($file, $resulttype = 'object', $encoding = 'utf-8') { $php_errormsg=""; $this->result=""; $this->evalCode=""; $values=""; if (!$data) $parser = xml_parser_create( $encoding ); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); $ok = xml_parse_into_struct($parser, $data, $values); if (!$ok) { xml_get_error_code($parser), xml_error_string(xml_get_error_code($parser)), xml_get_current_line_number($parser), xml_get_current_column_number($parser), xml_get_current_byte_index($parser)); } xml_parser_free($parser); if (!$ok) return $errmsg; if ($resulttype == 'array') return $this->xml_reorganize($values); // default $resulttype is 'object' return $this->array2object($this->xml_reorganize($values)); } ?>
wywołanie:
<?php $sxml = new simplexml; $data = $sxml->xml_load_file( $file, 'object', 'windows-1250' ); ?>
i błąd
Kod
xml_parser_create() unsupported source encoding "windows-1250"....
Z utf-8 działa elegancko ale na windowsowskim juz jest problem.
Co z tym fantem począć??
EDIT:
Rozwiązanie:
Przy wywołaniu
<?php $sxml = new simplexml; xml_parser_set_option($sxml,XML_OPTION_TARGET_ENCODING,'windows-1250'); $data = $sxml->xml_load_file( $file ); ?>