public static function populateXml($data)
  {
    $isFile = ( is_file($data) );
    
    libxml_use_internal_errors(true);
    
    if ( $isFile === true ){
      $xml = simplexml_load_file($data, '\SimpleXMLElement');
    }
    else {
      $xml = simplexml_load_string($data, '\SimpleXMLElement');
    }
    
    if ( empty($xml) ){
      $errors=[];
      if ( $isFile === true ){
        $errors[] = $data;
      }
      
      foreach(libxml_get_errors() as $error){
        $errors[] = 'XML: '.$error->message;
      }
      
      throw new Exception('XML file could not be loaded : '."\n".implode("\n", $errors));
    }
    
    return $xml;
  }