public static function import($file) { libxml_use_internal_errors(true); $xml = new DOMDocument(); if (!$xml->load($file)) { foreach (libxml_get_errors() as $error) { $text = ''; switch ($error->level) { case LIBXML_ERR_WARNING: $text .= S_XML_FILE_CONTAINS_ERRORS . '. Warning ' . $error->code . ': '; break; case LIBXML_ERR_ERROR: $text .= S_XML_FILE_CONTAINS_ERRORS . '. Error ' . $error->code . ': '; break; case LIBXML_ERR_FATAL: $text .= S_XML_FILE_CONTAINS_ERRORS . '. Fatal Error ' . $error->code . ': '; break; } $text .= trim($error->message) . ' [ Line: ' . $error->line . ' | Column: ' . $error->column . ' ]'; error($text); break; } libxml_clear_errors(); return false; } if ($xml->childNodes->item(0)->nodeName != 'zabbix_export') { $xml2 = self::createDOMDocument(); $xml2->appendChild($xml2->ownerDocument->importNode($xml->childNodes->item(0), true)); self::$xml = $xml2->ownerDocument; } else { self::$xml = $xml; } return true; }