public static function loadQtiXml($file) 
    {
        if ($file instanceof File) {
            $qti = $file->read();
        } else if (preg_match("/^<\?xml(.*)?/m", trim($file))) {
            $qti = $file;
        } else if (is_file($file)) {
            $qti = file_get_contents($file);
        } else {
            throw new \common_exception_Error("Wrong parameter. " . __CLASS__ . "::" . __METHOD__ . " accepts either XML content or the path to a file but got ".substr($file, 0, 500));
        }
        
        $dom = new DOMDocument('1.0', 'UTF-8');

        $domDocumentConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem')->getConfig('XMLParser');

        if (is_array($domDocumentConfig) && !empty($domDocumentConfig)) {
            foreach ($domDocumentConfig as $param => $value) {
                if (property_exists($dom, $param)) {
                    $dom->$param = $value;
                }
            }
        } else {
            $dom->formatOutput = true;
            $dom->preserveWhiteSpace = false;
            $dom->validateOnParse = false;
        }
        
        libxml_use_internal_errors(true);
        
        if (!$dom->loadXML($qti)) {
            $errors = libxml_get_errors();
            
            $errorsMsg = 'Wrong QTI item output format:' 
            . PHP_EOL 
            . array_reduce($errors, function ($carry, $item) {
                $carry .= $item->message . PHP_EOL;
                return $carry;
            });
            
            common_Logger::w($errorsMsg);
            
            throw new QtiModelException($errorsMsg);
        }
        
        return $dom;
    }