访问PHP SimpleXMLElement对象
我有一个这样的物体:访问PHP SimpleXMLElement对象,php,xml-parsing,Php,Xml Parsing,我有一个这样的物体: SimpleXMLElement Object ( [@attributes] => Array ( [url] => http://openclipart.org/people/jgm104/Expression_of_Emotions.svg [type] => image/svg+xml [length] => 485314 ) )
SimpleXMLElement Object
(
[@attributes] => Array
(
[url] => http://openclipart.org/people/jgm104/Expression_of_Emotions.svg
[type] => image/svg+xml
[length] => 485314
)
)
我如何从那里访问url
我尝试了$photos->item[$I]->enclosure->{“@attributes]”}
但它只显示空的SimpleXMLElement对象。您可以使用该方法访问所有选项
$photos->item[$i]->attributes()->url
您可以通过以下方式访问它:
$photos->item[$i]->enclosure->attributes()["attributeName"];
或
$miAttrList = $photos->item[$i]->enclosure->attributes();
echo $miAttrList["attributeName"];