protected function getXml($data)
{
if (extension_loaded('libxml')) {
libxml_use_internal_errors(true);
}
$simpleXml = simplexml_load_string($data);
if (!$simpleXml) {
if (extension_loaded('libxml')) {
$xmlErrors = libxml_get_errors();
$errors = array();
foreach ($xmlErrors as $error) {
$errors[] = sprintf('Error in file %s on line %d with message : %s', $error->file, $error->line, $error->message);
}
if (count($errors) > 0) {
throw new XmlException(implode("\n", $errors));
}
}
throw new XmlException('Xml file could not be loaded');
}
return $simpleXml;
}