Witam znalazłem klasę "simpleXML" pod PHP4 z tym ze jak chcę odczytać pliki z kodowaniem, windows-1250.
  1. <?php
  2. function xml_load_file($file, $resulttype = 'object', $encoding = 'utf-8')
  3.    {
  4.        $php_errormsg="";
  5.        $this->result="";
  6.        $this->evalCode="";
  7.        $values="";
  8.        $data = file_get_contents($file);
  9.        if (!$data)
  10.        return 'Cannot open xml document: ' . (isset($php_errormsg) ? $php_errormsg : $file);
  11.        
  12.        $parser = xml_parser_create( $encoding );
  13.        xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
  14.        xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
  15.        $ok = xml_parse_into_struct($parser, $data, $values);
  16.        if (!$ok) {
  17.            $errmsg = sprintf("XML parse error %d '%s' at line %d, column %d (byte index %d)",
  18.            xml_get_error_code($parser),
  19.            xml_error_string(xml_get_error_code($parser)),
  20.            xml_get_current_line_number($parser),
  21.            xml_get_current_column_number($parser),
  22.            xml_get_current_byte_index($parser));
  23.        }
  24.  
  25.        xml_parser_free($parser);
  26.        if (!$ok)
  27.        return $errmsg;
  28.        if ($resulttype == 'array')
  29.        return $this->xml_reorganize($values);
  30.        // default $resulttype is 'object'
  31.        return $this->array2object($this->xml_reorganize($values));
  32.    }
  33. ?>

wywołanie:
  1. <?php
  2. $sxml = new simplexml;
  3. $data = $sxml->xml_load_file( $file, 'object', 'windows-1250' );
  4. ?>


i błąd
Kod
xml_parser_create() unsupported source encoding &quot;windows-1250&quot;....

Z utf-8 działa elegancko ale na windowsowskim juz jest problem.
Co z tym fantem począć??

EDIT:
Rozwiązanie:
Przy wywołaniu
  1. <?php
  2. $sxml = new simplexml;
  3. xml_parser_set_option($sxml,XML_OPTION_TARGET_ENCODING,'windows-1250');
  4. $data = $sxml->xml_load_file( $file );
  5. ?>