Subject: | stripspaces not working correctly |
The attached file should have no content for the root node (if I
understand stripspaces correctly). Even if there was content, it should
not be a "1" for every record parsed and should be whitespace.
Subject: | tst.pl |
#!/usr/bin/perl
use strict;
use warnings;
use XML::Rules;
use Data::Dumper qw(Dumper);
my $xml = <<XML;
<root>
<record>
<a>a1</a>
<b>b1</b>
<c>c1</c>
</record>
<record>
<a>a2</a>
<b>b2</b>
<c>c2</c>
</record>
</root>
XML
my @rules = (
_default => sub {$_[0] => $_[1]->{_content}},
record => sub {
print Dumper $_[1];
my $r = $_[1];
my $str = join("|", @$r{qw(a b c)});
print "$str\n";
},
root => sub { print Dumper $_[1] },
);
my $xr = XML::Rules->new( rules => \@rules, stripspaces => 3|8 );
$xr->parse($xml);
__END__
$VAR1 = {
'c' => 'c1',
'a' => 'a1',
'b' => 'b1'
};
a1|b1|c1
$VAR1 = {
'c' => 'c2',
'a' => 'a2',
'b' => 'b2'
};
a2|b2|c2
$VAR1 = {
'_content' => '11'
};