开发者

Fixing quote error in invalid XML

开发者 https://www.devze.com 2023-02-26 00:56 出处:网络
A remote service generates invalid XML with attribute values without quotation marks. Example: <abc invalid=105 valid=\"105\">

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消