If you want to have a look at the latest development version at http://xmltwig.com/xmltwig/ , it should allow you to write complex handlers like the one you want.
--mirod
CPAN::Forum
XML-Twig - Re: specify path using bot tag names and attributes (using v3.25)