A remote service generates invalid XML with attribute values without quotation marks. Example:
<abc invalid=105 valid="105">
In PHP, how can I patch up such errors in the output? Just passing it to SimpleXML results in an error.
Thanks.
A remote service generates invalid XML with attribute values without quotation marks. Example:
<abc invalid=105 valid="105">
In PHP, how can I patch up such errors in the output? Just passing it to SimpleXML results in an error.
Thanks.
You are looking for tidy:
$input = '<abc invalid=105 valid="105">';
$tidy = new tidy();
$config = array('output-xml' => true);
$cleanXML = $tidy->repairString($input, $config);