이것은 내 xml 개체입니다. 내 스크립트의 개체 배열에서이를 구문 분석 할 수 없습니다.PHP SimpleXMLElement 속성에 액세스하는 방법은 무엇입니까?
foreach($xml2->users as $item) {
$userName = $item->attributes()->name;
}
내가 뭔가 잘못하고 있는가 : 여기
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 코드?
예제 번호 5를 참조하십시오. http://php.net/manual/en/simplexml.examples-basic.php – ymas
고마워요! 어리석은 실수. 그것은 효과가 있었다. –