xmllibxml01.pl to HTML.

index -|- end

Generated: Tue Feb 2 17:55:01 2010 from xmllibxml01.pl 2006/07/25 915.

#!/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);
}

index -|- top

checked by tidy  Valid HTML 4.01 Transitional