#!/Perl
use strict;
use XML::LibXML;
use Data::Dumper;

my $file = 'camelids01.xml';
my $parser = XML::LibXML->new();
my $tree = $parser->parse_file($file);
my $root = $tree->getDocumentElement;
my @species = $root->getElementsByTagName('species');

foreach my $camelid (@species) {
    my $latin_name = $camelid->getAttribute('name');
    #my @name_node  = $camelid->getElementsByTagName('common-name');
    my $name_node  = $camelid->getElementsByTagName('common-name');
    #my $common_name = $name_node[0]->getFirstChild->getData;
    my $common_name = "missing";
    #my @c_node  = $camelid->getElementsByTagName('conservation');
    my $c_node  = $camelid->getElementsByTagName('conservation');
    #my $status =  $c_node[0]->getAttribute('status');
    my $status =  "missed";
    print "$common_name ($latin_name) $status \n";
	print Dumper($name_node);
	print Dumper($c_node);
}

