I have a php file which prints an xml based on a MySql db.
I get an error every time at exactly the point where there is an & sign.
Here
&
in XML starts an entity. As you haven't defined an entity &WhateverIsAfterThat
an error is thrown. You should escape it with &
.
$string = str_replace('&', '&', $string);
How do I escape ampersands in XML
To escape the other reserved characters:
function xmlEscape($string) {
return str_replace(array('&', '<', '>', '\'', '"'), array('&', '<', '>', ''', '"'), $string);
}