use 5.008; use strict; use warnings; use DBI(); use XML::Smart; use Data::Dumper; #for debugging purposes only BEGIN { $| = 1 }; my $location = 'xxxxxx'; my $XML = XML::Smart->new($location.'CategoriesList.xml') or die("Unable to parse CategoriesList.xml: $!");; $XML = $XML->cut_root(); $XML = $XML->cut_root(); $dbh->do("DROP TABLE IF EXISTS ice_categories"); $dbh->do("CREATE TABLE ice_categories ( category_id int(11) not null, parent_cat_id int(11) not null, category_name varchar(100) not null default '', category_description varchar(100) not null default '', category_image varchar(100) not null default '', category_thumb varchar(100) not null default '', KEY (category_id), KEY (parent_cat_id)) CHARACTER SET utf8 COLLATE utf8_unicode_ci;"); my @Categories = @{$XML->{CategoriesList}{Category}}; my $c_categories = 0; foreach my $category (@Categories) { my $cat_name = ucwords($category->{Name}('langid','eq','1')->{Value}); #print $category->{ID} . " => " . $cat_name . "\n"; my $cat_desc = $category->{Description}('langid','eq','1')->{Value}; $dbh->do("INSERT ice_categories (category_id, parent_cat_id, category_name, category_description, category_image, category_thumb) VALUES (".$category->{ID}.", ".$cat_parent.", ".$dbh->quote($cat_name).", ".$dbh->quote($cat_desc).", ".$dbh->quote($category->{LowPic}).", ".$dbh->quote($category->{ThumbPic}).")"); $c_categories++; } print "$c_categories categories imported.\n"; } 1; #### networking netwerken