• strict warning: Non-static method view::load() should not be called statically in /home/s/serka1/devlib.ru/public_html/modules/views/views.module on line 879.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home/s/serka1/devlib.ru/public_html/modules/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_handler_filter::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home/s/serka1/devlib.ru/public_html/modules/views/handlers/views_handler_filter.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home/s/serka1/devlib.ru/public_html/modules/views/plugins/views_plugin_row.inc on line 0.
  • strict warning: Declaration of views_plugin_row::options_submit() should be compatible with views_plugin::options_submit(&$form, &$form_state) in /home/s/serka1/devlib.ru/public_html/modules/views/plugins/views_plugin_row.inc on line 0.

Uncaught exception 'Exception' with message 'String could not be parsed as XML

Возникла следующая ошибка в строке:

$xml = new SimpleXMLElement($data);

Здесь мы пытаемся распарсить невалидный XML и получаем следующую ошибку:

Uncaught exception 'Exception' with message 'String could not be parsed as XML

Как бороться? Будем отлавливать ошибку, вначале включаем:

libxml_use_internal_errors(true); 

Затем отлавливаем ошибку простым:

try{
    $xml = new SimpleXMLElement($data);
} catch (Exception $e){ 
    exit('Error');
}