//xml string  
$xml_string=" 
 
    
      Foo 
      foo@bar.com 
    
    
      Foobar 
      foobar@foo.com 
    
";  
  
//load the xml string using simplexml  
$xml = simplexml_load_string($xml_string);  
  
//loop through the each node of user  
foreach ($xml->user as $user)  
{  
   //access attribute  
   echo $user['id'], '  ';  
   //subnodes are accessed by -> operator  
   echo $user->name, '  ';  
   echo $user->email, '
'; }