|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-02-07 15:24 UTC] requinix@php.net
-Summary: No attributes with LIBXML_NOCDATA
+Summary: Attributes not shown in print_r output loading with
LIBXML_NOCDATA
-Status: Open
+Status: Verified
[2018-02-07 15:24 UTC] requinix@php.net
[2021-07-19 13:11 UTC] cmb@php.net
-Status: Verified
+Status: Duplicate
-Assigned To:
+Assigned To: cmb
[2021-07-19 13:11 UTC] cmb@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 14:00:01 2025 UTC |
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 ) ) )