【发布时间】:2016-07-06 21:37:26
【问题描述】:
这是我的 xml 对象。我无法在脚本的对象数组中解析它。
SimpleXMLElement Object(
[pagination] => SimpleXMLElement Object
(
[@attributes] => Array
(
[pageNumber] => 1
[pageSize] => 100
[totalAvailable] => 1
)
)
[users] => SimpleXMLElement Object
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[id] => xxxxxxxx
[name] => xxxxx
[siteRole] => xxxxx
[lastLogin] => xxxxxx
[externalAuthUserId] =>
)
)
)
)
这是我的 PHP 代码:
foreach($xml2->users as $item) {
$userName = $item->attributes()->name;
}
我做错了吗?
【问题讨论】:
-
谢谢!愚蠢的错误。它奏效了。
标签: php xml xml-parsing simplexml