3 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
4 if 0; # not running under some shell
10 print STDERR qq(Usage:
13 If no filename is given, supply XML on STDIN.
24 if ($ARGV[0] eq '-p') {
30 $xpath = XML::XPath->new(filename => shift(@ARGV));
33 $xpath = XML::XPath->new(ioref => \*STDIN);
36 my $nodes = $xpath->find(shift @ARGV);
38 unless ($nodes->isa('XML::XPath::NodeSet')) {
40 print $nodes->value, "\n";
45 $nodes = find_more($nodes);
46 goto NOTNODES unless $nodes->isa('XML::XPath::NodeSet');
50 foreach my $node ($nodes->get_nodelist) {
51 print $node->toString;
55 print STDERR "No nodes found";
68 my $newnodes = XML::XPath::NodeSet->new;
70 my $find = shift @ARGV;
72 foreach my $node ($nodes->get_nodelist) {
73 my $new = $xpath->find($find, $node);
74 if ($new->isa('XML::XPath::NodeSet')) {
75 $newnodes->append($new);
78 warn "Not a nodeset: ", $new->value, "\n";
82 return find_more($newnodes);