XML, the Perl Way

Processing XML with Perl Michel Rodriguez

Trees vs Streams

Tree processing

Stream Processing

The most resource-efficient model to process XML is the stream model.

The XML is processed as it is passed by the parser. Handlers are called for each event identified by the parser.

Pros

Cons

If your documents are too big to fit in memory (even if their size is an order of magnitude smaller than the memory available to your process) and/or if speed is really important for you you will have to use stream processing.

You can also choose to use this model if you are used to programming finite automata and you don't mind (or even enjoy!) managing contexts.



Trees vs Streams

Tree processing