in reply to print multi XML attributes using twig xml

The problem is that a Perl hash key can only have one value, but you assigned the Rs key to 3 values. Here is one way to get what you want:
use warnings; use strict; use XML::Twig; my $xml = <<XML; <foo> <Rs rsId="3894" snpClass="snp" snpType="notwithdrawn" molType="gen +omic" genotype="true" bitField="050028000005130500030100" taxId="9606 +"/> </foo> XML my $twig = XML::Twig->new ( twig_handlers => { 'Rs' => \&rs, } ); $twig->parse($xml); sub rs { my ($twig, $elt) = @_; print $elt->att('rsId'), "\n"; print $elt->att('snpType'), "\n"; print $elt->att('snpClass'), "\n"; } __END__ 3894 notwithdrawn snp

Replies are listed 'Best First'.
Re^2: print multi XML attributes using twig xml
by AhmedABdo (Acolyte) on Sep 10, 2015 at 15:14 UTC

    Thanks a lot, the problem is solved by your suggestion