#!/usr/bin/perl -w
###########################################
# xpserial - find all serial numbers of all
#        CDs by the Foo Fighters with XPath
# Mike Schilli, 2005 (m@perlmeister.com)
###########################################
use strict;
use XML::LibXML;

my $x = XML::LibXML->new() or
    die "new failed";

my $d = $x->parse_file("data.xml") or 
    die "parse failed";

my $serials = q{
    /result/cd/artists/
    artist[.="Foo Fighters"]/
    ../../@serial
};

for my $serial ($d->findnodes($serials)) {
    print $serial->value(), "\n";
}
