in reply to Re^2: Twig / Simple / xmlgrep --help
in thread Twig / Simple / xmlgrep --help
Then build the ruleset in the script, something like:
and called asuse XML::Rules; @ARGV == 5 or die "Usage: BookStore3.pl roottag datatag idtag fitertag + filtervalue\n"; my ( $roottag, $datatag, $idtag, $fitertag, $filtervalue) = @ARGV; my $parser = XML::Rules->new( rules => [ _default => 'content', $datatag => sub { return unless $_[1]->{$fitertag} eq $_[4]->{parameters}; my $id = delete $_[1]->{$idtag}; delete $_[1]->{'_content'}; return $id => $_[1] }, $roottag => 'pass no content', ] ); my $data = $parser->parse(\*DATA, $filtervalue); use Data::Dumper; print Dumper( $data); __DATA__ <?xml version="1.0" encoding="ISO-8859-1"?> <bookstore>
BookStore3.pl bookstore book title category CHILDREN
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Twig / Simple / xmlgrep --help
by Anonymous Monk on Aug 16, 2007 at 09:13 UTC | |
by Jenda (Abbot) on Aug 16, 2007 at 09:59 UTC | |
by Anonymous Monk on Aug 20, 2007 at 06:46 UTC |