File: xpath.pl

package info (click to toggle)
megaglest 3.13.0-9
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 13,416 kB
  • sloc: cpp: 144,271; ansic: 11,861; sh: 3,233; perl: 1,904; python: 1,751; objc: 142; asm: 42; makefile: 22
file content (23 lines) | stat: -rwxr-xr-x 442 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/perl -w

# Copyright 2011 olaus
# license: GPLv3 or newer
# show xpath in file, google xpath for syntax


if ( !@ARGV ) {
	die "\n\nusage $0 file xpath\n\n";
}

use strict;
use XML::XPath;
use XML::XPath::XMLParser;

my $xpath = XML::XPath->new( filename => shift @ARGV );

my $nodeset = $xpath->find( shift @ARGV );

foreach my $node ( $nodeset->get_nodelist ) {
        print XML::XPath::XMLParser::as_string( $node ) . "\n";
}