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

So, to make sure I understand this, would I be correct in saying both XML::Twig and XML::XPath each read the entire XML file into memory once, with the difference being that XML::Twig gets rid of it as soon as it gets the node(s) it wants to further process?

XML::XPath reads the entire document in memory, but XML::Twig does not necessarily.

If you just call new with no arguments and then parse an XML document, then it will build the entire tree in memory. But if you use the twig_handlers option when you create the obect, then you can call handlers during the parsing, and within those handlers you can call the flush, purge or delete methods to get rid of parts of the tree. You can also use the twig_roots option to process only the elements you need, and not all of the tree.

For more explanations you can have a look at the tutorial.