When you say <appDeploymentFile> as value I assume you want the value of the name attribute for the englobing appDeploymentFile element:
#!/usr/bin/perl use strict; use warnings; use XML::Twig; my %url2file; XML::Twig->new( twig_handlers => { url => sub { $url2file{$_->text}= $ +_->parent( 'appDeploymentFile')->att( 'name'); $_->purge; } } ) ->parsefile( "my_data.xml"); use YAML::Syck; print Dump( \%url2file);
Is this what you're looking for?
updated: give the result hash a meaningful name
In reply to Re: XML::Twig help please
by mirod
in thread XML::Twig help please
by Binford
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |