Parsing XML only returns first record

Parsing XML only returns first record

Hi,

I've got the following piece of PHP, which queries our CRM for any business who has a business listing and I want to retrieve their lats and longs to populate a Google Map

However, when the script runs and the simple_xml function is run, the foreach loop only outputs one record, it seems to not go through the xml file to pull out the rest of the entries in the XML file.

I'm seeing data so the API call is working, it's what's happening on the loop stage, which isn't working as expected

if(!function_exists('processGetCRMDetails')){
        function processGetCRMDetails($url, $param ){
            $ch = curl_init($url);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $param);
            /*If you have troubles with SSL connection try to add next curl option:*/
            //curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'rsa_rc4_128_sha');
            $result = curl_exec($ch);
            //curl_close($ch);
            return $result;
        }
    }
 
    $token = "***INSERT TOKEN***";

    $param = "authtoken=".$token."&scope=crmapi&selectColumns=Contacts(Account Name,Latitude,Longitude)&criteria=(Business Directory Listing:true)";


    $result = processGetCRMDetails($url, $param);
    
    $xml = simplexml_load_string($result, null, LIBXML_NOCDATA);
   
    
    foreach($xml->result->Contacts as $contact) {
        
        foreach($contact->row->FL as $FL){
            
            foreach($FL->attributes() as $attribute => $value){

               echo $FL;
                
           } 
               
        }
    }