File: test-path.pl

package info (click to toggle)
libxml-grove-perl 0.46alpha-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 204 kB
  • ctags: 158
  • sloc: perl: 1,057; makefile: 34
file content (32 lines) | stat: -rw-r--r-- 837 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#
#  Look in Path.pm for path usage
#

use XML::Parser;
use XML::Parser::Grove;
use XML::Grove;
use XML::Grove::Path;

die "usage: test-path.pl XML-FILE [PATH ...]\n"
    if ($#ARGV == -1);
my $doc = shift @ARGV;

my $parser = XML::Parser->new(Style => 'grove');
$parser->parsefile ($doc);
my $grove = $parser->{Grove};

my $path;
foreach $path (@ARGV) {
    print "$path = " . $grove->at_path($path) . "\n";
}

if ($doc =~ /REC-xml-19980210/) {
    $path = "/spec/header/title/[0]";
    print "$path = " . $grove->at_path($path) . "\n";
    $path = "/spec/header/pubdate/day/[0]";
    print "$path = " . $grove->at_path($path) . "\n";
    $path = "/spec/header/pubdate/month/[0]";
    print "$path = " . $grove->at_path($path) . "\n";
    $path = "/spec/header/pubdate/year/[0]";
    print "$path = " . $grove->at_path($path) . "\n";
}