[php-src] Issue #10514: simpleXML::asXML() puts children inside each other instead of next to each other while their value is empty

From: Date: Mon, 06 Feb 2023 08:13:08 +0000
Subject: [php-src] Issue #10514: simpleXML::asXML() puts children inside each other instead of next to each other while their value is empty
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-243651@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/10514 Author: THeiligensetzer ### Description The following code: ```php $procadmuster =<<<XML <?xml version="1.0" encoding="UTF-8" ?> <PROCADMUSTER> <test/> <test2/> <test3/> </PROCADMUSTER> XML; $xml2 = new SimpleXMLIterator($procadmuster); echo '<p id="xml2">'.$xml2->asXML().'</p>'; <?php ``` Resulted in this output: ``` <?xml version="1.0" encoding="UTF-8" ?> <PROCADMUSTER> <test> <test2> <test3/> </test2> </test> </PROCADMUSTER> ``` But I expected this output instead: ``` <?xml version="1.0" encoding="UTF-8" ?> <PROCADMUSTER> <test/> <test2/> <test3/> </PROCADMUSTER> ``` This problem occurs with and without attributes. It doesn't matter if I use that xml string or add children with "->addChild()".The only workaround I found is to add a space to each element "->addChild('name', ' ')". Before $xml2 I generated $xml which doesn't contain empty child Elements and works as expected because of it.. ### PHP Version PHP 8.2.0 ### Operating System Windows 10 Pro 22H2

« previous php.bugs (#243651) next »