#!/bin/perl -w

#########################################################################
#                                                                       #
#  This example displays the name of a player whose id is given         #
#  It uses the elt_id method, by default the id attribute will be 'id'  #
#                                                                       #
#########################################################################

use strict;
use XML::Twig;

my $id= "player" . shift;

my $twig= new XML::Twig();

if( $ARGV[0]) { $twig->parsefile( $ARGV[0]); }        # parse a file
else          { $twig->parse( \*STDIN);      }        # parse the standard input

my $player= $twig->elt_id( $id);                      # this gets the element

print "$id: " . $player->first_child( 'name')->text . "\n";
