开发者

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜