tags:

views:

64

answers:

1
+4  A: 

From the docs for XML::Twig:

end_tag_handlers

A hash { expression => \&handler}. Sets element handlers that are called when the element is closed (at the end of the XML::Parser End handler). The handlers are called with 2 params: the twig and the tag of the element.

twig_handlers are called when an element is completely parsed, so why have this redundant option? There is only one use for end_tag_handlers: when using the twig_roots option, to trigger a handler for an element outside the roots.

You're setting up an end handler for your auto element, which is the root. And you're only using twig_roots for apps. So the end handler will never be called.

You should install your handler using twig_handlers instead.

So try this:

my $twig = XML::Twig->new(
        start_tag_handlers => 
          { 'auto' => \&loading
          },
        twig_handlers =>
          { 'apps/title' => \&kicks,
            'apps/logs' => \&bye,
            'auto'      => \&finish
          },
        twig_roots =>
          { 'apps' => \&app
          },
        );
friedo
Thank you very much,It was really work. And I had question about XML::Twig before and I read doc again,Alas my English skills also problem...Now really understand start_tag_handlers section in XML::Twig doc by your answer.
tknv