#!/usr/bin/perl use strict; use warnings; use XML::Twig; use Data::Dumper; my $test_xml = qq| Unix 999 28 |; my $t= XML::Twig->new( twig_handlers => { 'CustDetails' => sub { $_->first_child('CustomerId')->text(), } } ) ->parse($test_xml); warn Dumper $t; # I am trying to get this: 999 # in instead, I am getting this: =code $VAR1 = bless( { 'twig_xmldecl' => { 'version' => '1.0', 'standalone' => undef, 'encoding' => 'ISO-8859-1' }, 'twig_keep_pi' => 1, 'twig_current' => undef, 'twig_autoflush' => 1, 'twig_space_policy' => { 'CustDetails' => 0 }, 'twig_entity_list' => bless( { 'updated' => 0, 'entities' => {} }, 'XML::Twig::Entity_list' ), 'twig_do_not_escape_amp_in_atts' => 0, 'twig' => $VAR1, 'NoExpand' => 0, 'twig_keep_comments' => 1, 'twig_discard_spaces' => 1, '_twig_context_stack' => undef, 'twig_elt_class' => 'XML::Twig::Elt', 'twig_id' => 'id', 'twig_parsing' => undef, 'Non_Expat_Options' => { 'NoLWP' => 1, 'Non_Expat_Options' => 1, '_HNDL_TYPES' => 1, 'Handlers' => 1, 'Style' => 1 }, 'Handlers' => { 'CdataEnd' => sub { "DUMMY" }, 'Default' => sub { "DUMMY" }, 'CdataStart' => sub { "DUMMY" }, 'Start' => sub { "DUMMY" }, 'Comment' => sub { "DUMMY" }, 'Entity' => sub { "DUMMY" }, 'End' => sub { "DUMMY" }, 'Final' => sub { "DUMMY" }, 'Doctype' => sub { "DUMMY" }, 'Char' => sub { "DUMMY" }, 'Init' => sub { "DUMMY" }, 'Attlist' => sub { "DUMMY" }, 'Element' => sub { "DUMMY" }, 'ExternEnt' => sub { "DUMMY" }, 'XMLDecl' => sub { "DUMMY" }, 'Proc' => sub { "DUMMY" } }, 'twig_ext_ent_handler' => sub { "DUMMY" }, 'trailing_spaces' => ' ', 'twig_handlers' => { 'xpath_handler' => { 'Age' => undef, 'CustomerId' => undef, 'CustName' => undef, '*' => undef, 'CustDetails' => [ { 'trigger' => sub { "DUMMY" }, 'handler' => sub { "DUMMY" }, 'test_on_text' => 0, 'path' => 'CustDetails', 'score' => { 'steps' => 1, 'type' => 3, 'anchored' => 0 }, 'tag' => 'CustDetails' } ] }, 'handlers' => { 'string' => { 'CustDetails' => $VAR1->{'twig_handlers'}{'xpath_handler'}{'CustDetails'}[0]{'handler'} } } }, 'TwigHandlers' => { 'CustDetails' => $VAR1->{'twig_handlers'}{'xpath_handler'}{'CustDetails'}[0]{'handler'} }, 'extra_data' => '', 'Pkg' => 'XML::Twig', '_HNDL_TYPES' => { 'CdataEnd' => sub { "DUMMY" }, 'Start' => sub { "DUMMY" }, 'Entity' => sub { "DUMMY" }, 'ExternEntFin' => sub { "DUMMY" }, 'End' => sub { "DUMMY" }, 'Final' => 1, 'Doctype' => sub { "DUMMY" }, 'Char' => sub { "DUMMY" }, 'Init' => 1, 'XMLDecl' => sub { "DUMMY" }, 'Default' => sub { "DUMMY" }, 'CdataStart' => sub { "DUMMY" }, 'Comment' => sub { "DUMMY" }, 'Unparsed' => sub { "DUMMY" }, 'ExternEnt' => sub { "DUMMY" }, 'Element' => sub { "DUMMY" }, 'Attlist' => sub { "DUMMY" }, 'DoctypeFin' => sub { "DUMMY" }, 'Notation' => sub { "DUMMY" }, 'Proc' => sub { "DUMMY" } }, 'twig_keep_encoding' => 0, 'twig_dtd_handler' => undef, 'twig_in_pcdata' => 0, 'twig_parser' => undef, 'twig_stored_spaces' => ' ', 'twig_root' => bless( { 'gi' => '6', 'first_child' => bless( { 'next_sibling' => bless( { 'next_sibling' => bless( { 'parent' => $VAR1->{'twig_root'}, 'gi' => '9', 'prev_sibling' => $VAR1->{'twig_root'}{'first_child'}{'next_sibling'}, 'first_child' => bless( { 'parent' => $VAR1->{'twig_root'}{'first_child'}{'next_sibling'}{'next_sibling'}, 'gi' => 1, 'pcdata' => '28' }, 'XML::Twig::Elt' ), 'att' => {}, 'last_child' => $VAR1->{'twig_root'}{'first_child'}{'next_sibling'}{'next_sibling'}{'first_child'} }, 'XML::Twig::Elt' ), 'parent' => $VAR1->{'twig_root'}, 'gi' => '8', 'prev_sibling' => $VAR1->{'twig_root'}{'first_child'}, 'first_child' => bless( { 'parent' => $VAR1->{'twig_root'}{'first_child'}{'next_sibling'}, 'gi' => 1, 'pcdata' => '999' }, 'XML::Twig::Elt' ), 'att' => {}, 'last_child' => $VAR1->{'twig_root'}{'first_child'}{'next_sibling'}{'first_child'} }, 'XML::Twig::Elt' ), 'parent' => $VAR1->{'twig_root'}, 'gi' => '7', 'first_child' => bless( { 'parent' => $VAR1->{'twig_root'}{'first_child'}, 'gi' => 1, 'pcdata' => 'Unix' }, 'XML::Twig::Elt' ), 'att' => {}, 'last_child' => $VAR1->{'twig_root'}{'first_child'}{'first_child'} }, 'XML::Twig::Elt' ), 'att' => {}, 'last_child' => $VAR1->{'twig_root'}{'first_child'}{'next_sibling'}{'next_sibling'}, 'twig' => $VAR1 }, 'XML::Twig::Elt' ) }, 'XML::Twig' ); =cut