#!/usr/bin/perl --
use strict;
use warnings;
use XML::Twig;
sub get_style {
my @style;
XML::Twig->new(
twig_handlers => {
'?xml-styleshet' => sub {
my ( $t, $pi, $data ) = @_;
XML::Twig->new(
twig_handlers => {
stylesheet => sub {
push @style, $_->atts;
},
},
)->parse("");
return;
},
},
)->parse(@_);
return @style;
}
my $xml = <<'__XML__';
__XML__
use Data::Dumper;
print Data::Dumper->new( [ get_style($xml) ] )->Indent(1)->Dump;
__END__
$VAR1 = {
'href' => 'stylesheet1.xsl',
'type' => 'text/xsl'
};
$VAR2 = {
'href' => 'stylesheet2.xsl',
'type' => 'text/xsl'
};
$VAR3 = {
'href' => 'stylesheet3.xsl',
'type' => 'text/xsl'
};