Php 访问SimpleXMLElement对象值

Php 访问SimpleXMLElement对象值,php,xml,object,Php,Xml,Object,我的代码如下: SimpleXMLElement Object( [@attributes] => Array( [id] => 542 [url] => http://google.pl [price] => 19.29 [avail] => 1 [set] => 0 ) ) 如何使用PHP访问id?试试这个 $attributes = $simpleXmlEl

我的代码如下:

SimpleXMLElement Object(
    [@attributes] => Array(
        [id] => 542
        [url] => http://google.pl
        [price] => 19.29
        [avail] => 1
        [set] => 0
    )
)
如何使用PHP访问id?

试试这个

$attributes = $simpleXmlElement->attributes();
echo $id = $attributes['id'];
试试这个

$attributes = $simpleXmlElement->attributes();
echo $id = $attributes['id'];
我可以像这样得到身份证

我可以得到这样的“id”

可能的重复