in reply to XML::Twig Search

I'd use the following, but Twig's limited XPath support cannot handle it:
use strict; use warnings; use XML::Twig qw( ); my $twig = XML::Twig->new( twig_roots => { 'Application[Properties/Timeout]' => sub { my ($t, $elt) = @_; print("$elt->{att}{Name}\n"); $t->purge; } }, ); $twig->parsefile('a.xml');

This works:

use strict; use warnings; use XML::Twig qw( ); my $twig = XML::Twig->new( twig_handlers => { 'Application/Properties/Timeout' => sub { my ($t, $elt) = @_; print($elt->parent->parent->att('Name'), "\n"); }, }, ); $twig->parsefile('a.xml');

Replies are listed 'Best First'.
Re^2: XML::Twig Search
by Gizmo (Novice) on May 17, 2010 at 20:40 UTC
    Thanks, I see it matches any Application/Properties/Timeout so if I have many levels it detects it, exactly what I was trying to do.