【问题标题】:How to access element attributes with SimpleXml? [duplicate]如何使用 SimpleXml 访问元素属性? [复制]
【发布时间】:2011-06-05 05:35:37
【问题描述】:

我如何在 php 中访问属性值:

[photos] => SimpleXMLElement Object
    (
        [@attributes] => Array
            (
                [page] => 1
                [pages] => 1
                [perpage] => 24
                [total] => 18
            )

我尝试了以下方法:

$photos->@attributes['total'] ;
$photos->{'@attributes'}['total'] ;

还有很多变体

【问题讨论】:

标签: php simplexml


【解决方案1】:

只是

echo $photos['total'];

Example #5 Using attributes

【讨论】:

猜你喜欢
  • 2012-04-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-12-23
  • 2011-04-14
  • 2013-08-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多