You can also access the node as an array to get attributes:
<?php
$xml = simplexml_load_file('file.xml');
echo 'Attribute: ' . $xml['attribute'];
?>
|  | SimpleXMLElement->attributes(no version information, might be only in CVS)SimpleXMLElement->attributes -- Identifies an element's attributes DescriptionSimpleXMLElement simplexml_element->attributes ( [string data] )This function provides the attributes and values defined within an xml tag. 
 
  add a note
  User Contributed Notes 
  skerr at mojavi dot org 10-Dec-2004 02:55 
You can also access the node as an array to get attributes:
  christian at koch dot net 09-Nov-2004 04:35 
PHP5:: I think this is a fine solution to get the attributes easier...
  sveta at microbecal dot com 30-Oct-2004 06:03 
Namespace handling example:
  tychay at php dot net 29-Sep-2004 01:04 
BTW, It occurs to me that why do you need the function anyway? You just access it directly as (string) $object[$attribute].
  tychay at php dot net 29-Sep-2004 07:31 
Why bother iterating over all the elements when they are already indexed? something like...
  Eirik Sletteberg 12-Sep-2004 09:21 
In reply to inge at elektronaut dot no's function:
  inge at elektronaut dot no 27-May-2004 01:53 
here's a simple function to get an attribute by name, based on the example |  | |