Index: /branches/release-41/plugins/WXRImporter/lib/WXRImporter/WXRHandler.pm
===================================================================
--- /branches/release-41/plugins/WXRImporter/lib/WXRImporter/WXRHandler.pm (revision 2515)
+++ /branches/release-41/plugins/WXRImporter/lib/WXRImporter/WXRHandler.pm (revision 2716)
@@ -69,6 +69,11 @@
     $self->{in_wp_comment_content} = 1 if ('wp' eq $prefix) && ('comment_content' eq $name);
 
-    push @{$self->{'bucket'}}, \%values if scalar(%values);
-    push @{$self->{'bucket'}}, $prefix . '_' . $name;
+    if ( scalar(%values) ) {
+        push @{ $self->{'bucket'} },
+          { $prefix . '_' . $name => undef, _a => \%values };
+    }
+    else {
+        push @{ $self->{'bucket'} }, $prefix . '_' . $name;
+    }
     1;
 }
@@ -86,5 +91,5 @@
     my $chars = MT::I18N::utf8_off($data->{Data});
     if ('HASH' eq ref($element)) {
-        my @hash_array = %$element;
+        my @hash_array = grep { $_ ne '_a' } keys %$element;
         return unless $hash_array[0];
         my $val = $element->{$hash_array[0]};
@@ -119,5 +124,4 @@
     }
     push @{$self->{'bucket'}}, $element;
-
     my $name_element = $prefix . '_' . $name;
     if ('_item' eq $name_element) {
@@ -127,4 +131,6 @@
     } elsif ('wp_category' eq $name_element) {
         $self->_create_category($data);
+    } elsif ('wp_tag' eq $name_element) {
+        $self->_create_tag($data);
     } elsif ('wp_comment' eq $name_element) {
         $self->_create_feedback($data);
@@ -253,4 +259,38 @@
             return die MT->translate(
                  "Saving category failed: [_1]", $cat->errstr);
+        }
+    }
+}
+
+sub _create_tag {
+    my $self = shift;
+    my $data = shift;
+
+    my $cb   = $self->{callback};
+    my $blog = $self->{blog};
+
+    require MT::Tag;
+    my $tag = MT::Tag->new;
+    my $set_name;
+    while ( my $hash = pop @{ $self->{'bucket'} } ) {
+        last if 'wp_tag' eq $hash;
+        next if 'HASH' ne ref $hash;
+        my @hash_array = %$hash;
+        my $key        = $hash_array[0];
+        my $value      = $hash_array[1];
+        if ( 'wp_tag_name' eq $key ) {
+            return if ( MT::Tag->load( { name => $value } ) );
+            $tag->name($value);
+            $set_name = 1;
+        }
+    }
+    if ($set_name) {
+        $cb->( MT->translate( "Creating new tag ('[_1]')...", $tag->name ) );
+        if ( $tag->save ) {
+            $cb->( MT->translate("ok") . "\n" );
+        }
+        else {
+            $cb->( MT->translate("failed") . "\n" );
+            return die MT->translate( "Saving tag failed: [_1]", $tag->errstr );
         }
     }
@@ -451,4 +491,5 @@
     };
     my %meta_hash;
+    my @tags;
 
     my $class = MT->model($class_type);
@@ -462,7 +503,7 @@
     $post->status($blog->status_default);
     for my $hash (@$hashes) {
-        my @hash_array = %$hash;
+        my @hash_array = grep { $_ ne '_a' } keys %$hash;
         my $key = $hash_array[0];
-        my $value = $hash_array[1];
+        my $value = $hash->{ $hash_array[0] };
         if ('_title' eq $key) {
             $post->title($value);
@@ -482,4 +523,9 @@
                 $cat_ids{$cat->id} = 1;
                 $primary_cat_id = $cat->id unless $primary_cat_id;
+            }
+            if ( $hash->{_a} ) {
+                if ( $hash->{_a}->{domain} eq 'tag' ) {
+                    push @tags, $value;
+                }
             }
         } elsif ('_guid' eq $key) {
@@ -589,4 +635,9 @@
     }
 
+    # Associate tags to the entry.
+    if (@tags) {
+        $post->set_tags(@tags);
+    }
+
     # Now save the entry/page.
     if ('entry' eq $class_type) {
