[php-src] Issue #12170: Can't use xpath with comments in SimpleXML

From: Date: Sun, 10 Sep 2023 19:30:00 +0000
Subject: [php-src] Issue #12170: Can't use xpath with comments in SimpleXML
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-245377@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12170 Author: nielsdos ### Description The following code: ```php <?php $sxe = simplexml_load_string(<<<XML <?xml version="1.0"?> <container> <!-- comment --> </container> XML); var_dump($sxe->xpath("//comment()")); ``` Resulted in this output: ``` array(0) { } ``` But I expected this output instead: ``` array(1) { [0] => the comment node } ``` However, you can see the comment node with var_dump($sxe): ```php object(SimpleXMLElement)#1 (1) { ["comment"]=> object(SimpleXMLElement)#2 (0) { } } ``` So SimpleXML can handle it, kinda. ### PHP Version PHP 8.1+ ### Operating System Linux

« previous php.bugs (#245377) next »