I am trying to parse the following xml but my code blew parses the first tag of each section only,
$xml = simplexml_load_string($response);       
foreach ($xml->person as $p) {
  $p = $p->attributes()->name;
  echo "     ".$p. "        ";
}
The output is Joe Ray Alex, but I need it to show the name of every person in the list, so it should be Joe Jack Ray John Edward Alex.
 <?xml version="1.0" encoding="utf-8"?>
 <people>
   <person name="Joe">
   <person name="Jack">
   </person>
   </person>
   <person name="Ray">
   <person name="John">
   <person name="Edward">
   </person>
   </person>
   <person name="Alex">
   </person>
 </people>
Is there any other option rather than changing the xml? because I receive the xml as a response from a web service.
 
     
     
     
    