There is an xml file with Unicode encoding that was loaded using the POST method. How can something be changed in it and saved for further use? simplexml_load_file () says that Unicode is not supported. I had to decode myself.
It turned out to decode, but now how to encode? with bad codings. While doing this:
function decode_xml($xml){ $arr = str_split($xml); $text = ''; foreach ($arr as $key => $value) { if(preg_match("/[A-Za-z0-9]|\<|\>|\"|\'|\/|\=|\?|\ |\,|\./", $value)){ $text .= $value; } } $text = str_replace("Unicode", 'Utf-8', $text); $xml = simplexml_load_string($text); return $xml; } function encode_xml($decoded_xml){ //?? } if($_FILES){ $new_path = 'C:\Program Files (x86)\Bloody6\Bloody6\Data\RES\English\SLED\Standard\new2.ckAnimation'; $tmp = $_FILES['file']['tmp_name']; $xml = file_get_contents($tmp); // $xml = < ? x m l v e r s i o n = " 1 . 0 " e n c o d i n g = " U n i c o d e " ? > $decoded_xml = decode_xml($xml); //раскодировать $xml var_dump($decoded_xml); //Вывести содержимое $encoded_xml = encode_xml($decoded_xml); //Закодировать file_put_contents($new_path, $encoded_xml); //сохранить } An example of this xml: https://drive.google.com/open?id=0B58cr0kXJtKIUms1ekxDOEQwNGM