Processing XML efficiently with XML::Twig

Michel Rodrigues

IEEE Standards Activities

Thursday, 2:15 PM in Rangos III.

See http://standards.ieee.org/resources/spasystem/twig/

XML::Twig is one of the 225 Perl modules that do XML processing. My main main goal when developping it was to combine efficiency and ease. It had to be fast and memory effective, while still allowing tree-processing of XML documents.
 
The talk will explain how I (hope I) reached this goal, describing XML::Twig and its various processing models, giving examples for each of them.
 
XML::twig allows a script to load an XML document in memory and to process it in tree-mode, navigating and editing the tree before printing it. The tree can also be processed as the document is being parsed, by defining handlers on element. Parts of the whole tree that are no longer used can be purged (freeing the memory) or flushed (output and purged).
 
The last processing model allows a script to define handlers only for a subset of theDTD, all other element are simply discarded, or output as-is, without building the tree. This allows fast "local" processing and is very well suited to pipeline processing.
 
Some additional tricks, such as optimizing element name storage, or "de-objectifying" the module by definig inline subs (the subs are inlined when the module is installed) will also be described.
 

Next | Previous | Author list | Schedule | YAPC 19100