0

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?

4

1 回答 1

1

您可以使用数组访问语法访问节点属性:

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

文档中:

SimpleXML 还可以访问元素属性。像访问数组元素一样访问元素的属性。

于 2013-09-04T23:22:05.453 回答