How do you deal with broken data in XML files? For example, if I had
<text>Some &improper; text here.</text>
I am trying to do:
$doc = new DOMDocument(); $doc->validateOnParse = false; $doc->formatOutput = false; $doc->load(...xml');
and he fails because there is an unknown entity. Note that I cannot use CDATA because of the way the software is written. I write a module that reads and writes XML, and sometimes the user inserts the wrong text.
I noticed that DOMDocument-> loadHTML () encodes everything beautifully, but how can I continue from there?
Tower source share