Simplexml_load_string不会加载所有内容

I want to load all xml values into array

for example, i've the following xml

<rating>
<kp_rating num_vote="14008">8.665</kp_rating>
<imdb_rating num_vote="94758">8.8</imdb_rating>
</rating>

using Simplexml_load_string i'm getting only

SimpleXMLElement Object ( [kp_rating] => 8.665 [imdb_rating] => 8.8 )

How can I get in addition the num_vote?

You can access the node attributes using the array access syntax:

$xml->kp_rating['num_vote']
$xml->imdb_rating['num_vote']

From the documentation:

SimpleXML can also access element attributes. Access attributes of an element just as you would elements of an array.