Quick patch:
*** LX.pm.old 2012-01-18 11:24:23.000000000 -0500
--- LX.pm 2012-01-18 11:34:59.000000000 -0500
***************
*** 101,109 ****
XML could be L<XML::LibXML::Document>, L<XML::LibXML::DocumentPart> or
string
! =head2 hash2xml $hash, [ doc => 1, ] [ OPTIONS ]
! Id C<doc> option is true, then returned value is
L<XML::LibXML::Document>, not string
=head1 OPTIONS
--- 101,109 ----
XML could be L<XML::LibXML::Document>, L<XML::LibXML::DocumentPart> or
string
! =head2 hash2xml $hash, [ return => 'd'|'e'|'s', ] [ OPTIONS ]
! If C<return> option is 'd', then returned value is
L<XML::LibXML::Document>. If 'e', then the value is an
L<XML::LibXML::Element>. Otherwise, a string is returned. (The C<doc
=E<gt> 1> option is still supported for backwards-compatibility.)
=head1 OPTIONS
***************
*** 508,514 ****
#warn "hash2xml(@_) from @{[ (caller)[1,2] ]}";
my $hash = shift;
my %opts = @_;
! my $str = delete $opts{doc} ? 0 : 1;
my $encoding = delete $opts{encoding} || delete $opts{enc} ||
'utf-8';
my $doc = XML::LibXML::Document->new('1.0', $encoding);
local @H2X{keys %opts} = values %opts if @_;
--- 508,515 ----
#warn "hash2xml(@_) from @{[ (caller)[1,2] ]}";
my $hash = shift;
my %opts = @_;
! my $return = lc delete $opts{return};
! $return //= delete $opts{doc} ? 'd' : 's';
my $encoding = delete $opts{encoding} || delete $opts{enc} ||
'utf-8';
my $doc = XML::LibXML::Document->new('1.0', $encoding);
local @H2X{keys %opts} = values %opts if @_;
***************
*** 516,523 ****
#use Data::Dumper;
#warn Dumper \%H2X;
my $root = _h2x($hash);
$doc->setDocumentElement($root);
! return $str ? $doc->toString : $doc;
}
=head1 BUGS
--- 517,525 ----
#use Data::Dumper;
#warn Dumper \%H2X;
my $root = _h2x($hash);
+ return $root if ($return eq 'e');
$doc->setDocumentElement($root);
! return $return eq 'd' ? $doc : $doc->toString;
}
=head1 BUGS