Having spent a few hours researching I have been unable to come up with an answer for this. I am trying to send an XML string to a third party so I need to encode some characters, in this case single and perhaps double quotes. I use the PHP XML Dom to achieve this but the saveXML() function always unencodes quotes it seems. A very simple example is below and when you view the output, ' has been replaced with ' but the others still have their codes. Can anyone explain why this is and how I can get around it (without doing a str_replace). Thanks.
$XMLDoc = new DOMDocument('1.0', 'utf-8');
$comments = $XMLDoc->createElement('Comments');
$text = $XMLDoc->createElement('Text', "An apostrophe here < ' > Pound sign: £");
$comments->appendChild($text);
$XMLDoc->appendChild($comments);
echo $XMLDoc->saveXML();