private function _loadXml($filename)
    {
        $xmls = array();
        libxml_use_internal_errors(true);
        if (is_array($filename)) {
            foreach ($filename as $file) {
                $result = $this->_loadXml($file);
                if ($result !== false) {
                    foreach ($result as $name => $xml) {
                        $xmls[$name] = $xml;
                    }
                }
            }
            return $xmls;
        }
        $contents = false;
        foreach ($this->_directories as $directory) {
            $fullname = $directory . DIRECTORY_SEPARATOR . $filename;
            if (!file_exists($fullname)) {
                continue;
            }
            $contents = @file_get_contents($fullname);
        }
        if ($contents === false) {
            throw new BeanFactoryException($filename . ' not found in ' . print_r($this->_directories, true));
        }
        $ret = simplexml_load_string($contents);
        if ($ret === false) {
            return $ret;
        }
        $xmls[$filename] = $ret;
        foreach ($ret->xpath("//import") as $imported) {
            $filename = (string)$imported->attributes()->resource;
            foreach ($this->_loadXml($filename) as $name => $xml) {
                $xmls[$name] = $xml;
            }
        }
        return $xmls;
    }