php-src/ext/dom/tests/xml_parsing_LIBXML_RECOVER.phpt
Niels Dossche 035a5fdf8c
Add LIBXML_RECOVER (#13504)
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
2024-02-25 21:03:37 +01:00

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>