NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
No need for XML::Filter::Simple (Score:2, Informative)
XML::Simple can pretty much do that already. The difference is that in your example you ignore the return value from the parse and the hashref (or 'simple tree') ends up inside the handler object itself. But this is how you'd do it with XML::Simple:
Re:No need for XML::Filter::Simple (Score:3, Funny)
Re:No need for XML::Filter::Simple (Score:2)
Re:No need for XML::Filter::Simple (Score:2, Informative)
You might want to look into XML::Filter::Dispatcher which I think can do what you want (ie: treat sections of the document as documents in their own right).
Digging inside XML::Simple.pm wouldn't actually help (and might harm your sanity) since all the handler does is accumulate the events in an XML::Parser Tree-style structure and then once the whole document has been parsed it uses the 'collaspe' method to convert it to a simple tree.
Re:No need for XML::Filter::Simple (Score:2)
A little late... you can do this using XML::Twig: the latest version lets you use the simplify method on any element of the tree. simplify gives you the same structure as XML::Simple. And of course you can use it during the parsing, so you can deal with parts of the tree.
Example:
mirod
Re: Politics::US (Score:1)
------------------------------
You are what you think.
Re: Politics::US (Score:2)
Re: Politics::US (Score:1)
I'd definately be interested to hear about it -- I personally try to be a political agnostic, but it doesn't always work.
------------------------------
You are what you think.