In the below code I'm trying to access @attributes of Userinfo as $somevariable->Userinfo->attributes(); which is perfectly fine, but when there is no @attributes it throws an error
Call to a member function attributes() on null
[Userinfo] => SimpleXMLElement Object
(
[@attributes] => Array
(
[UserId] => 121
[UserName] => Arun, Singh
[UserEmail] => [email protected]
[CreatedDate] => 06/27/2018 08:44:21
)
)
So, before accessing @attributes, how to check if it exist ?
Thank you.
Userinfois not there rather than the attributes missing.UserinfoI'm getting from api dynamically, for some case it was not received I guess.