Q:

How do I access XML attributes in PHP with simplexml? 

Hello, I have this piece of XML:
<foo id="whatever" default="whatever">
  FOO
</foo>

How can I access attributes like id or default? 
If I print_r($xml->foo) I see them, but they are prepended with @ 

A:

Use the array syntax for attributes and object syntax for child nodes:
$xml->foo['id']  // get `id` attribute on `foo` node

See the Using attributes example here: http://docs.php.net/manual/en/simplexml.examples-basic.php#example-4741
See also the attributes() method.