[英]Access PHP SimpleXMLElement object
I have an object like this: 我有一个像这样的对象:
SimpleXMLElement Object
(
[@attributes] => Array
(
[url] => http://openclipart.org/people/jgm104/Expression_of_Emotions.svg
[type] => image/svg+xml
[length] => 485314
)
)
How can I acces the url from there? 我如何从那里访问网址?
I tried $photos->item[$i]->enclosure->{"@attributes]"}
but it show only blank SimpleXMLElement objects. 我尝试了$photos->item[$i]->enclosure->{"@attributes]"}
但它只显示空白的SimpleXMLElement对象。
You can use method SimpleXMLElement::attributes to get access for all options. 您可以使用方法SimpleXMLElement :: attributes来获取所有选项的访问权限。
$photos->item[$i]->attributes()->url $ photos->项[$ i]于 - >属性() - > URL
You can acces to it this a way: 您可以通过以下方式访问它:
$photos->item[$i]->enclosure->attributes()["attributeName"];
or 要么
$miAttrList = $photos->item[$i]->enclosure->attributes();
echo $miAttrList["attributeName"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.