ID:               51154
 User updated by:  mr at inpay dot com
 Reported By:      mr at inpay dot com
 Status:           Bogus
 Bug Type:         SimpleXML related
 Operating System: Windows 7 Professional
 PHP Version:      5.3.1
 New Comment:

Ohh, thanks alot. Wasn't aware of that syntax.


Previous Comments:
------------------------------------------------------------------------

[2010-02-26 09:14:26] [email protected]

This works fine, so long as you use the right syntax. Example 3 at 
http://au2.php.net/manual/en/simplexml.examples-basic.php covers this.

In your case, you would access http-code as follows:

$httpCode = $xml->{'http-code'};

------------------------------------------------------------------------

[2010-02-26 08:40:34] mr at inpay dot com

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.

------------------------------------------------------------------------

[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

Reply via email to