in reply to XML::Simple noisy option?

You might want to consider using the SAX events that XML::Simple (and many other XML parsers) can generate.

Rather than process the entire XML document in memory, the parser will generate events (for example the start or end of an element) which can then be used to trigger a handler, which can:


As well as keeping resource usage down, you can print the new document to the browser as you process it.

Cheers.

BazB

Update: Added a few suggestions of what SAX events could be used to trigger.

Update 2: mirod++. I've not been able to confirm XML::Simple's behaviour regarding having to slurp the whole file before producing SAX events, but I'll bow to mirod's superior knowledge in this area :-) mirod's idea of using a SAX filter is cunning.


If the information in this post is inaccurate, or just plain wrong, don't just downvote - please post explaining what's wrong.
That way everyone learns.

Replies are listed 'Best First'.
Re: Re: XML::Simple noisy option?
by mirod (Canon) on Jan 30, 2003 at 00:34 UTC

    I don't think this would work. I haven't read that part of the code, but I believe you still have to slurp the entire document in memory with XMLin and process it before you start emitting SAX events using XMLout.

    What could work is using a SAX parser, and setting up a SAX filter that would spur out messages before passing the data untouched to XML::Simple. Or even using a tee like XML::Filter::Tee so that both XML::Simple and a separate SAX handler receive the input. That handler can then spit out a message depending on where it is in the parsing.

    OTOH playing with signals to send an "everything is OK" message every x second might be quite simpler ;--)