use XML::LibXML; use XML::Fast; use XML::Simple; use XML::Bare; use XML::Compile::Schema; use Data::Dumper; $XML::Simple::PREFERRED_PARSER='XML::Parser'; # Found this great tip from perlmonks use Benchmark qw/cmpthese/; $doc='XML String '; my $schema = XML::Compile::Schema->new('./myschema.xsd'); my $reader = $schema->compile(READER => '{myns}mytype'); # I have done this outside to compile schema once but not sure if it works like that cmpthese timethese -10, { libxml => sub { XML::LibXML->new->parse_string($doc) }, xmlfast => sub { XML::Fast::xml2hash($doc) }, xmlbare => sub { XML::Bare->new(text => $doc)->parse }, xmlsimple => sub { XML::Simple->new(ForceArray => 0, KeyAttr => {})->XMLin($doc); }, xmlcompile => sub {my $hash = $reader->("$doc");}, };