You could place your handler at dl level. Note that in this case the pretty_print do not work properly. The code looks a little simpler though:
#!/usr/bin/perl -w use strict; use XML::Twig; XML::Twig->new( twig_roots => { dl => sub { $_->subs_text( qr/(.+?)\s+ +(.+?)\n/, '&elt(first + => $1)&elt( second => $2)' ) ->print; }, }, twig_print_outside_roots => 1, ) ->parse( \*DATA); __DATA__ <c> <dl> ABC CDE add eerwe sdfsdfs erewrwe </dl> </c>
In reply to Re: problem using XML Twig
by mirod
in thread problem using XML Twig
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |