0

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.

hub
  • 29
  • 3

1 Answers1

1

You are looking for tidy:

$input = '<abc invalid=105 valid="105">';
$tidy = new tidy();
$config = array('output-xml' => true);
$cleanXML = $tidy->repairString($input, $config);
phihag
  • 278,196
  • 72
  • 453
  • 469