Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: XML::Twig -vs- XML::XPath

by leriksen (Curate)
on Oct 14, 2004 at 01:34 UTC ( #399072=note: print w/replies, xml ) Need Help??

in reply to XML::Twig -vs- XML::XPath

... would I be correct in saying both XML::Twig and XML::XPath each read the entire XML file into memory once

Looking at the doc for XML::Twig I would say not. Like the example I gave, XML::Parser is used, because it is SAX-based and therefore very kind to memory - only the parts you specify are in memory once the parse is complete.

From the doco for XML::Twig

This module provides a way to process XML documents. It is build on top of XML::Parser.

It allows minimal resource (CPU and memory) usage by building the tree only for the parts of the documents that need actual processing, ...

As for XML::XPath, it doesn't mention it explicitly, but a quick surf through the source for its internal class XML::XPath::XMLParser, shows that it too uses XML::Parser. And it declares handlers for the events of XML::Parser. But it seems to build up an internal tree (of arrayrefs, and the author states the reason for this is speed). I see lots of code like $self->{current}->appendChild($node, 1);
so perhaps it is does build an internal image first.

Why not test with a huge XML doc and watch the memory footprint via ps or top

use brain;

Replies are listed 'Best First'.
Re^2: XML::Twig -vs- XML::XPath
by buttroast (Scribe) on Oct 14, 2004 at 16:39 UTC

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://399072]
[holli]: is there anybody out there?
[shmem]: the world is full of people - out there...
[holli]: are you sure? or are they mere prjections of my hallucinating mind?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2017-09-22 20:46 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (269 votes). Check out past polls.