Bug #75929 [Opn->Ver]: Attributes not shown in print_r output loading with LIBXML_NOCDATA

From: Date: Wed, 07 Feb 2018 15:24:09 +0000
Subject: Bug #75929 [Opn->Ver]: 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-213845@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: requinix@php.net Reported by: victor-vansloun at hotmail dot com -Summary: No attributes with LIBXML_NOCDATA +Summary: Attributes not shown in print_r output loading with LIBXML_NOCDATA -Status: Open +Status: Verified Type: Bug Package: SimpleXML related Operating System: Linux, Apache, Plesklin PHP Version: 7.1.14 Block user comment: N Private report: N New Comment: Trying to access the attributes easily proves they are there. Just not visible in the print_r output. https://3v4l.org/tJnmm Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#213845) next »