Thanks. I'll see if I can improve the docs. Especially regarding the "x-path-like" stuff. That thing is fairly underdocumented.
The code without using the "helper" would be
use XML::Rules;
my $parser = XML::Rules->new(
stripspaces => 7,
rules => {
fruit => 'as array',
fruits => 'pass no content',
'average-color' => [
'fruit' => sub {return 'fruit-average-color' => $_[1]->{_c
+ontent}},
'fruits' => sub {return 'global-average-color' => $_[1]->{
+_content}},
sub {},
]
}
);
my $data = $parser->parse(\*DATA);
use Data::Dumper;
print Dumper($data);
__DATA__
<fruits>
<average-color>purple</average-color>
<fruit type="banana">
<average-color>yellow</average-color>
</fruit>
<fruit type="apple">
<average-color>greenish</average-color>
</fruit>
</fruits>