use XML::Simple; $data = XMLin( \*DATA, KeepRoot => 1, ForceArray => [ qw/attribute/ ] ); @attrs = map { $_->{category} } # We want the category value map { @{ $_->{attributes}{attribute} } } # for each attribute values %{ $data->{dataschemas}{dataschema} }; # in all dataschemas. print "@attrs\n"; __DATA__