PCDATA invalid Char value 1 — ошибка при чтении XML
При формировании XML:
$text=preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u',' ',$text);
Полная функция:
function prepare_to_xml($text){ $text=preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u',' ',$text); $text=strip_tags($text); $text=htmlspecialchars($text); $text=str_replace("\t"," ",$text); $text=str_replace(" "," ",$text); $text=str_replace(" "," ",$text); $text=preg_replace("/[\r\n]+/i","",$text); $text=preg_replace('/ {2,}/',' ',$text); $text=trim($text); return $text; }
Ну или просто:
function utf8_for_xml($string){ return preg_replace('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u',' ',$string); }