in reply to Prune Twig From Huge XML File

You can use the ignore_elts => { content => 1 } option to ignore content.

I am a bit surprised by the performances you mention though, especially as my tests (a little dated, but AFAIK not much has changed since) indicated that XML::Sax was quite slow. What perl version is this on?

Replies are listed 'Best First'.
Re^2: Prune Twig From Huge XML File
by andergoo (Initiate) on Mar 16, 2009 at 20:54 UTC
    Hi, Thanks for the quick response, wow! I'll try that, thanks. I had already tried $content->ignore, but it didn't seem to speed things up. I am using 5.8. Perhaps the reason SAX was so quick is that is feeds data to a handler in chunks which I can ignore as soon as soon as my maximum length is reached...? Dunno, I am a beginner...

      It makes sense, I'll have to look at it tomorrow, it is indeed likely that XML::Twig reads the entire content of the element (worse than that, it probably buffers it, which implies copying it a few times...) before discarding it. I'll see if I can improve this.

Re^2: Prune Twig From Huge XML File
by Anonymous Monk on Mar 17, 2009 at 08:59 UTC
     ignore_elts works like a charm, thanks!