XML, the Perl Way
Welcome to the XML::Twig Page.
XML::Twig is a Perl module used to process efficiently XML documents
Twig offers a tree-oriented interface to a document while still allowing the processing of documents of any size. I think the current buzzword for it would be "push-pull" processing ;--)When I was younger I wanted to grow up and write a tool that would allow people to process text the way they wanted, offering tons of feature, various ways to achieve the same result, not forcing them into any processing model but allowing them to use the one they felt the most comfortable with. Eventually I grew up and I realized a guy named Larry Wall had already written a language named Perl... Darn! So as I was quite involved in dealing with SGML, then XML, I decided to settle for the next best thing: writing a module that would allow people to process XML the way they wanted, offering them tons of feature, various ways... you get the point.So I wrote XML::Twig. XML::Twig gives you a tree interface to XML documents... if you want. It also lets you dump parts of the tree, set callbacks during processing, both on tags and on subtrees, process only part of the tree, write powerful filters... you name it. The only thing XML::Twig does not do is follow standards (except XML of course): no DOM, no XPath (well, not quite, it implements a subset of XPath), no SAX ( it is planned though, as of 3.05 you can output SAX using the toSAX1 and toSAX2 methods). Consider yourself warned!
Git repo:mirod's xmltwig master, ongithub
XML::Twig page on seach.cpan.org
Mirrors onCPAN
Development version:html ortext,Changes
Stable version:html ortext,Changes
TheXML::Twig Quick Reference Page
You can also have a look at theFAQ (updatedSat Jun 16 06:32:56 2012)
Thedevelopment version documentation is probably the easiest to use: it is better cross-referenced, methods are sorted alphabetically and you can expand/collapse method lists.
A completetutorial, covering XML::Twig basics, integrating XML documents with data bases, HTML conversion and more...
Note that I wrote it back in the days of version 1.10 or so so it does not include some of the latest additions to the module. It should get you started though!
TheWays to Rome series of articles has examples of how to use XML::Twig (along withmany other modules).
Kip Hampton also wrote an very good article:Using XML::Twig forxml.com.
Tom Anderson has an interesting article:Performance Comparison Between SAX XML::Filter::Dispatcher and XML::Twig. I have improved slightly the XML::Twig version of his test, seemy comments.
Finally, I cannot really comment onXML-Twig, by Stas Orlenko, an article in Russian ;--(
A 2 hour introduction to XML::Twig:Growing Twigs, gives a generic discussion on XML processing, how to install XML::Twig, code examples and a quick history of the module.
Finally, you can hear me talk about my favourite subjet in an interview with Josh McAdams onperlcast:Michel Rodriguez on XML::Twig.
You can file bug reports and view outstanding bugs throught the XML::Twig bug list, usingrt.cpan.org
The latestcoverage.
BTW, a good way to help the development of XML::Twig is to write more tests to increase this coverage. Look atthis source and work on getting rid of uncovered branckes (the ones with red numbers). Just make sure the tests are portable accross various OSs and versions of Perl. Coverage is already pretty good but it is always better to increase it.
All the examples:twig_examples.tar.gz
A series of examples on a single xml file
The data is a list of perl modules inex_fm.xml. To run the examples:ex_fm<n> ex_fm.xml.
An example using 2 documents and$twig->finish_print to speed up processing. To run it:ex_insert insert_new<n>.xml insert_main.xml
And finally:Examples of XML::Twig on Perlmonks, a list of my posts about XML::Twig onPerlMonks.
If you want to support XML::Twig's development, I always appreciate anything fromXML::Twig's wishlist on Amazon. Thanks.
Last Updated:Thu Dec 24 18:48:22 2015
copyrigh © 1998-2015 - Michel Rodriguez -www.xmltwig.com