If you're using SimpleXML objects, is already have an attributes
method built into it (without the @
sign) -- use it like this: $product->attributes('part_number');
If you're trying to create your own objects to map to the XML, then as you already found out, you can't use the @
symbol in a PHP variable name (nor any other symbol except underscore).
I'd suggest simply using $product->attributes['part_number']
(ie without the @
symbol at all) and mapping it inside your class.
If you really need to map it into your variable names, the best you can really hope for would be some kind of replacement string that you can swap in and out as you convert between the two formats.
eg: $product->at__attributes['part_number']
But that's not really a particularly good solution, IMHO.