Answer the question
In order to leave comments, you need to log in
How to clean xml file from invalid characters?
An xml file comes to the site from another program, which often contains a string
PHP cannot parse the file - it gives an error
Warning: simplexml_load_string(): Entity: line 34365: parser error : xmlParseCharRef: invalid xmlChar value 4 in
I try to clean it up before parsing:<UNITS> Not Applicable</UNITS>
$str = file_get_contents($file_xml);
$str = str_replace('', '', $str);
$xml = simplexml_load_string($str);
Answer the question
In order to leave comments, you need to log in
Most likely the problem is that the file encoding is different from yours, read here:
www.cyberforum.ru/php-beginners/thread707907.html
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question