When I try to access the @attributes created by simplexml i get the following error:
Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or `'{'' or `'$'' in C:\wamp\www\php_sandbox\rex_test.php on line 11
the code is a such:
foreach ($xml->token as $value){
echo "key == " .$value->@attributes['key'];
}
Is there a setting in PHP that is wrong?
SimpleXMLElement
Moderator: General Moderators
Re: SimpleXMLElement
@attributes is not a valid variable name so you can't use it that way.
Try SimpleXML's array syntax version instead.
Try SimpleXML's array syntax version instead.
Code: Select all
$value["key"]Re: SimpleXMLElement
Thanks that did it.