in reply to Re: accessing root tags when using XML::Twig and twig_roots
in thread accessing root tags when using XML::Twig and twig_roots

If I use a start_tag_handler for the root element, then I can't have "roots" that are a subset of the whole document.

If I set the "roots" within the first callback, what happens to the printout? I have a partial open going on and it hasn't started printing outside of roots yet. Whatever happens, will it be well-behaved?

  • Comment on Re^2: accessing root tags when using XML::Twig and twig_roots

Replies are listed 'Best First'.
Re^3: accessing root tags when using XML::Twig and twig_roots
by Argel (Prior) on May 04, 2006 at 20:27 UTC
    Couldn't you do two passes against the file? First create a twig with the start_tag_handler to get whatever it is you need. Then use that information to create a second twig for the actual processing. Would that work or am I missing something? As mirod mentions some sample code and data might help clear things up.
      Yes, that is an option, now that I know how to quit once I find what was needed. Someone said that die from a handler will do the trick, presumably without leaving the module in a funny state.
Re^3: accessing root tags when using XML::Twig and twig_roots
by mirod (Canon) on May 04, 2006 at 19:37 UTC

    What did you try? I find it easier to get some code to work than to answer questions like these ;--(