code: static protected function fromHTML($method, $arg, &$errors)
      {
          $old = libxml_use_internal_errors(true);
          $cnt = count(libxml_get_errors());
  
          $dom = new DOMDocument;
          $dom->$method($arg);
  
          $errors = array_slice(libxml_get_errors(), $cnt);
          libxml_use_internal_errors($old);
  
          return simplexml_import_dom($dom, __CLASS__);
      }
docs: NOTE: in order to support LSB, __CLASS__ would need to be replaced by get_called_class() and
  this method would need to be invoked via static:: instead of self::
  @param $method
  @param $arg
  @param $errors
  @return \SimpleXMLElement