Fixing quote error in invalid XML
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);
精彩评论