mirror of
https://github.com/php/php-src.git
synced 2025-08-17 14:38:49 +02:00

Setting the recovery option by using a hardcoded value (1) worked already for SimpleXML. For DOM, a small change is necessary because otherwise the recover field overwrites the recovery option. From a quick search on GitHub [1] it looks like this won't clash with existing PHP code as no one seems to define (or use) a constant with such a name. [1] https://github.com/search?q=LIBXML_RECOVER+language%3APHP&type=code&l=PHP
23 lines
501 B
PHP
23 lines
501 B
PHP
--TEST--
|
|
XML parsing with LIBXML_RECOVER
|
|
--EXTENSIONS--
|
|
dom
|
|
--FILE--
|
|
<?php
|
|
|
|
$dom = new DOMDocument;
|
|
$dom->loadXML('<root><child/>', options: LIBXML_RECOVER);
|
|
echo $dom->saveXML();
|
|
|
|
$dom = DOM\XMLDocument::createFromString('<root><child/>', options: LIBXML_RECOVER);
|
|
echo $dom->saveXML(), "\n";
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Warning: DOMDocument::loadXML(): %s
|
|
<?xml version="1.0"?>
|
|
<root><child/></root>
|
|
|
|
Warning: DOM\XMLDocument::createFromString(): %s
|
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
<root><child/></root>
|