PHP: <?php function create_query_to_movie($xml_filename) { libxml_use_internal_errors(TRUE); $simplexml = simplexml_load_file($xml_filename); if ($simplexml === FALSE) { echo "There were errors parsing the XML file.\n"; foreach(libxml_get_errors() as $error) { echo $error->message; } exit; } $query = "CREATE TABLE IF NOT EXISTS `movie` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `orig_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `description` text COLLATE utf8_unicode_ci, `year` int(4) NOT NULL DEFAULT '0', `rating` float DEFAULT NULL, `poster` varchar(255) CHARACTER SET utf8 NOT NULL DEFAULT '', `add_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `category_id` tinyint(4) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;".PHP_EOL; $query .= 'INSERT INTO `movie` (`name`, `orig_name`, `year`, `rating`, `poster`,`category_id`) '.PHP_EOL.'VALUES '; //ниже местами не помешает addslashes() foreach($simplexml as $movie) { $title = isset($movie->title_russian) ? $movie->title_russian : ''; $title_orign = isset($movie->title_original) ? $movie->title_original : ''; $year = isset($movie->year) ? $movie->year : ''; $rating = isset($movie->imdb) ? "'".$movie->imdb->attributes()->rating."'" : 'NULL'; $poster = isset($movie->poster->big) ? $movie->poster->big->attributes()->url : ''; $query .= sprintf("('%s', '%s', '%s', %s, '%s', '%s'),\n", $title, $title_orign, $year, $rating, $poster, 1); } return chop($query, ",\n").';'; } echo '<pre>'; echo create_query_to_movie('movies.xml'); ?>