projects
/
irspy-moved-to-github.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
3fb001a
)
New file, irspy-xpath.pl
author
Mike Taylor
<mike@miketaylor.org.uk>
Wed, 21 Jul 2010 15:29:13 +0000
(16:29 +0100)
committer
Mike 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]
patch
|
blob
diff --git a/bin/irspy-xpath.pl
b/bin/irspy-xpath.pl
new file mode 100755
(executable)
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);