#51154 [Opn]: SimpleXMLElement does not support dash in nodename

From: Date: Fri, 26 Feb 2010 08:40:35 +0000
Subject: #51154 [Opn]: SimpleXMLElement does not support dash in nodename
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148072@lists.php.net to get a copy of this message
ID: 51154 User updated by: mr at inpay dot com Reported By: mr at inpay dot com Status: Open Bug Type: SimpleXML related Operating System: Windows 7 Professional PHP Version: 5.3.1 New Comment: Oops, but accident i switched the "Expected result" and "Actual result" Expected result should be SimpleXMLElement Object ( [http_code] => 200 ) Actual result should be SimpleXMLElement Object ( [http-code] => 200 ) Sorry for the inconvinience. Previous Comments: ------------------------------------------------------------------------ [2010-02-26 08:38:41] mr at inpay dot com Description: ------------ Having a XML string, where one or more of the nodenames contains a - (dash) it is impossible to return that value, as dash is not allowed in attributes on an object. Consider replacing all dash'es with underscores. Reproduce code: --------------- <?php $xml_string = "<response><http-code>200</http-code></response>"; $xml = new SimpleXMLElement($xml_string); print_r($xml); ?> Expected result: ---------------- SimpleXMLElement Object ( [http-code] => 200 ) Actual result: -------------- SimpleXMLElement Object ( [http_code] => 200 ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=51154&edit=1

« previous php.bugs (#148072) next »