I'm creating a XML file with SimpleXMLElement like this :
$xml = new SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><DonneesDepot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"></DonneesDepot>');
I insert some data and I save with:
$xml->asXML($path);
When I save, this automatically encode &
, >
, <
, but I need to encode the quotes, so when I insert my data I use htmlspecialchars()
:
htmlspecialchars($some_data, ENT_XML1 | ENT_QUOTES, 'UTF-8')
This encode the quotes with '
but then because of the encoding on saving this encode as &apos;
,
How can I do to save the file and encoding also the quotes or save the file without any encoding and then I could use htmlspecialchars()
when I insert my data?