Parse XML with @params

There is XMLreceived from a third-party server:

object(SimpleXMLElement)#4 (1) {
  array(5) {
    string(1) "0"
    string(11) "**********"
    string(1) "1"
    string(1) "1"
    string(3) "0,6"

Either I’m stupid or I just don’t understand, I need to pull out the values ​​of @attributes


But how do I get to $xml->@attributes? You can’t put the sign @– you can’t.

Answer 1, authority 100%

You can use get_object_vars:

$a = get_object_vars($xml);


In the case of PHP 5.3 it is possible without crutches:

$xml = simplexml_load_string($str);
$a = (array)$xml;

Answer 2

Alternatively, work like an array: $xml[‘message_cost’] will return “0.6”.