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

From: Date: Fri, 26 Feb 2010 08:38:42 +0000
Subject: #51154 [NEW]: SimpleXMLElement does not support dash in nodename
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-148071@lists.php.net to get a copy of this message
From:             mr at inpay dot com
Operating system: Windows 7 Professional
PHP version:      5.3.1
PHP Bug Type:     SimpleXML related
Bug description:  SimpleXMLElement does not support dash in nodename

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 bug report at http://bugs.php.net/?id=51154&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51154&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51154&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51154&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51154&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51154&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51154&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51154&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51154&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51154&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51154&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51154&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51154&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51154&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51154&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51154&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51154&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51154&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51154&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51154&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51154&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51154&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#148071) next »