To give you the leg up here is your updated example in XML::Twig
use strict;
use warnings;
use XML::Twig;
XML::Twig->new(
twig_handlers => {
'c1/rrcConnectionSetupComplete' => \&my_stuff,
}
)->parsefile( 'uL-DCCH-Message.xml' );
sub my_stuff {
my ($twig, $elt) = @_;
my $rrc_trans_identifier = $elt->field( 'rrc-TransactionIdentifier' );
print "rrc_trans_id :: $rrc_trans_identifier\n";
my $twiglet = $elt->first_child('criticalExtensions')
->first_child('c1')
->first_child('rrcConnectionSetupComplete-r8');
my $selected_plmn_id = $twiglet->first_child_text('selectedPLMN-Identity');
print "plmn identity :: $selected_plmn_id\n";
my $rrc_dedicated_info_nas = $twiglet->first_child_text('dedicatedInfoNAS');
print "dedicated info nas :: $rrc_dedicated_info_nas\n";
$twig->purge;
}
This outputs exactly what you were after:
rrc_trans_id :: 2
plmn identity :: 1
dedicated info nas :: 07410109014290112345671000028020000f0
Important
Above works for the example you provided but there are a few different ways you could achieve the same result in XML::Twig depending on what your exact requirements are.
Please don't assign me with the accepted answer for this question! Chas & eugene were first on the scene with the correct answer to your problem and brian followed up with the ubiquitous answer.
/I3az/