Q:

XML attributes function error say Called on a non-object

I have XML file I want to retrieve the attribute names from it by using this code below. the code work and retrieve all attribute names but under the last attribute names also show this error
 Fatal error: Call to a member function attributes() on a non-object in C:\wamp\www\php\xml\EnglishArabic\new.php on line 13

 <?php
    $en = simplexml_load_file('ENstrings.xml');
    $enlen = sizeof($en->string);
    for ($i=0; $i<=$enlen ; $i++) { 
        foreach ($en->string[$i]->attributes() as $key => $value) {
           echo $value. '<br \>';
        }
    }
?>

A:

That's because the index ($en->string[$i]) starts from 0 to length-1, so your loop supposed to stop just before $i reaches the length : 
for ($i=0; $i<$enlen ; $i++) { 

