in reply to Re^3: Parsing XML
in thread Parsing XML

Yeah, this worked:
my $val; my $t= XML::Twig->new( twig_handlers => { 'CustDetails' => sub { $val = $_->first_child('Custome +rId')->text(), } } ) ->parse($test_xml); print $val;

I wish it was less complicated for such a simple example on how to use XML::Twig - Could it be simpler just using RegExp?

Thank you!

Replies are listed 'Best First'.
Re^5: Parsing XML
by AnomalousMonk (Archbishop) on Sep 02, 2016 at 18:30 UTC
    I wish it was less complicated for such a simple example on how to use XML::Twig - Could it be simpler just using RegExp?

    A simple example may simply hide the tangled inherent complexity of XML. Heed the wise advice of Corion. Resist the temptation to use regexes; that way lies madness!


    Give a man a fish:  <%-{-{-{-<