Bug #75929 [Ver->Dup]: Attributes not shown in print_r output loading with LIBXML_NOCDATA
| From: | cmb@php.net | Date: | Mon, 19 Jul 2021 13:11:28 +0000 |
| Subject: | Bug #75929 [Ver->Dup]: Attributes not shown in print_r output loading with LIBXML_NOCDATA | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235179@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=75929&edit=1
ID: 75929
Updated by: cmb@php.net
Reported by: victor-vansloun at hotmail dot com
Summary: Attributes not shown in print_r output loading with
LIBXML_NOCDATA
-Status: Verified
+Status: Duplicate
Type: Bug
Package: SimpleXML related
Operating System: Linux, Apache, Plesklin
PHP Version: 7.1.14
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Even if LIBXML_NOCDATA is not passed, the ouput of the second item
is not correct; this is already tracked as bug #61597.
Previous Comments:
------------------------------------------------------------------------
[2018-02-07 15:24:09] requinix@php.net
Trying to access the attributes easily proves they are there. Just not visible in the print_r
output.
https://3v4l.org/tJnmm
------------------------------------------------------------------------
[2018-02-07 14:51:44] victor-vansloun at hotmail dot com
Description:
------------
The simplexml_load_string function loads attributes correctly when no options are specified. But
when the LIBXML_NOCDATA option used, attributes are not specified.
Test script:
---------------
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<root>
<item>
<foo id=\"1\"><![CDATA[123]]></foo>
<bar><![CDATA[abc]]></bar>
</item>
<item>
<foo id=\"1\">123</foo>
<bar>abc</bar>
</item>
</root>";
print_r(simplexml_load_string($xml, null, LIBXML_NOCDATA));
Expected result:
----------------
SimpleXMLElement Object
(
[item] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => 1
)
[foo] => 123
[bar] => abc
)
[1] => SimpleXMLElement Object
(
[foo] => 123
[bar] => abc
)
)
)
Actual result:
--------------
SimpleXMLElement Object
(
[item] => Array
(
[0] => SimpleXMLElement Object
(
[foo] => 123
[bar] => abc
)
[1] => SimpleXMLElement Object
(
[foo] => 123
[bar] => abc
)
)
)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=75929&edit=1