#!/usr/bin/perl --
use strict; use warnings;
use XML::Rules;
use Data::Dump qw/ dd /;
my $ta = XML::Rules->new(
qw/ stripspaces 8 /,
rules => [
_default => 'raw',
],
);
my $da = XML::Rules->new(
qw/ stripspaces 8 /,
rules => [
a => 'content',
_default => 'raw',
],
);
dd $ta->parse( q() );
dd $da->parse( q() );
dd $da->parse( q(tada) );
__END__
[
"a",
{
_content => [
["b", { type => 1 }],
["b", { type => 2 }],
["c", {}],
["b", { type => 3 }],
],
},
]
{
a => [
["b", { type => 1 }],
["b", { type => 2 }],
["c", {}],
["b", { type => 3 }],
],
}
{
a => [
["b", { type => 1 }],
["b", { type => 2 }],
["c", {}],
["b", { _content => "tada", type => 3 }],
],
}
####
$ xsh -q
$scratch/> open pm981718.xml
/> ls /
tada
/> for /a/* { pwd }
/a/b[1]
/a/b[2]
/a/c
/a/b[3]
/> for /a/* { pwd; print @type; }
/a/b[1]
1
/a/b[2]
2
/a/c
/a/b[3]
3
/> for /a/* { pwd; for(@*){ echo xsh:path(.) " = " xsh:current(); }; };
/a/b[1]
/a/b[1]/@type = 1
/a/b[2]
/a/b[2]/@type = 2
/a/c
/a/b[3]
/a/b[3]/@type = 3
/>
/> quit
saving .../.xsh2_history
done