I'm taking over a previous developer's project. The code is building a large XML document a little at a time, appending new XML to the same variable as it goes along. The problem is the data sometimes has invalid characters.
For example:
$xml .= "<name>Jack & Jill</name>";
$xml .= "<street>123 Mary's Lake Road</street>";
I'm looking for a way to clean up the XML data all at once, like this:
$xml = safeXML($xml);
It seems like building such a function ought to be simple, but so far everything I've found either requires valid XML to start with, or else goofs up the XML tags themselves.
(I know it would be better to format the XML properly before building the document, but this is complex code and as usual the client wants it done yesterday. ;) )