New file, irspy-xpath.pl
authorMike Taylor <mike@miketaylor.org.uk>
Wed, 21 Jul 2010 15:29:13 +0000 (16:29 +0100)
committerMike Taylor <mike@miketaylor.org.uk>
Wed, 21 Jul 2010 15:29:13 +0000 (16:29 +0100)
bin/irspy-xpath.pl [new file with mode: 0755]

diff --git a/bin/irspy-xpath.pl b/bin/irspy-xpath.pl
new file mode 100755 (executable)
index 0000000..e90a81a
--- /dev/null
@@ -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);