From: Mike Taylor Date: Wed, 21 Jul 2010 15:29:13 +0000 (+0100) Subject: New file, irspy-xpath.pl X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=dc38a63af16624cd340710736f87f0af6e3120a1;p=irspy-moved-to-github.git New file, irspy-xpath.pl --- diff --git a/bin/irspy-xpath.pl b/bin/irspy-xpath.pl new file mode 100755 index 0000000..e90a81a --- /dev/null +++ b/bin/irspy-xpath.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl + +# Execute a specific XPath against provided XML, having established +# prefixes for the namespaces used in IRSpy. + +use ZOOM::IRSpy::Utils qw(irspy_xpath_context); + +use strict; +use warnings; + +my $xpath = shift(); +my $xml = join("", <>); +my $xc = irspy_xpath_context($xml) + or die "$0: can't make XPath context"; +my @nodes = $xc->findnodes($xpath); +print scalar(@nodes), " hits\n"; +print join("", map { $_->to_literal() . "\n" } @nodes);