Fixed RSS multiple category with XML::RSS::LibXML
[catagits/XML-Feed.git] / lib / XML / Feed / Format / RSS.pm
index e29123c..248debd 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: RSS.pm 1934 2006-04-22 05:13:55Z btrott $
+# $Id$
 
 package XML::Feed::Format::RSS;
 use strict;
@@ -34,7 +34,7 @@ sub init_string {
     my($str) = @_;
     $feed->init_empty;
     if ($str) {
-        $feed->{rss}->parse($$str);
+        $feed->{rss}->parse($$str, { hashrefs_instead_of_strings => 1 } );
     }
     $feed;
 }
@@ -245,11 +245,16 @@ sub content {
 }
 
 sub category {
-    my $item = shift->{entry};
+    my $entry = shift;
+    my $item  = $entry->{entry};
     if (@_) {
-        $item->{category} = $item->{dc}{subject} = $_[0];
+        my @tmp = ($entry->category, @_);
+        $item->{category}    = [@tmp];
+        $item->{dc}{subject} = [@tmp];
     } else {
-        $item->{category} || $item->{dc}{subject};
+        my $r = $item->{category} || $item->{dc}{subject};
+        my @r = ref($r) eq 'ARRAY' ? @$r : defined $r? ($r) : ();
+        return wantarray? @r : $r[0];
     }
 }