Hacker News new | ask | show | jobs
by mirod1 552 days ago
The basic reason to use XML::Twig as opposed to XSLT would be to do XML processing while still having access to all of Perl's power, DB access, file system integration etc... things that can be clunky to do in XSLT.

For what it's worth I have used XSLT too, and the basic programming patterns are surprisingly similar: an XPath selector triggers some code, the code has access to the XML tree. In both cases you have to pay some attention to when that code is being triggered. I prefer the XML::Twig way, to being able to use a regular programming language in the code, partly because I am used to it, but also because the XSLT XML syntax ends up being quite verbose, and leads to delimiter collisions.

XML::Twig also lets you work with "too big to fit in memory" XML, by working at sub-tree level in a nicer (IMHO) way than SAX. I am sure there are other ways these days, but the module dates back to last century, so at the time that was pretty unique.

I assume that other languages also have convenient XML libraries, so if you're more familiar with them and they work for you, then you should use them!