My continuing dream of a Perl XML(::Twig) cookbook
I ran into Michel Rodriguez at YAPC, so I started talking to him about my idea for an XML::Twig cookbook. I really, really love his module and want more people to use it. It takes a bit to get used to, so I think it's ideally suited for some cookbook-style documentation.
His advice is that XML::Twig is what you use when parsing and futzing with XML is not the primary purpose of your program (e.g., you have some config files to read). That turned into a bit of a discussion with those around us about when you should use which XML modules, and that we should answer the same cookbook recipes with examples from multiple modules (like a Bobby Flay cook-off, I guess).
- Use XML::Simple if it does exactly what you want. When it doesn't do exactly what you want (i.e. you have to configure it), stop using it.
- Use XML::Twig for light XML tasks, mild processing, etc.
- Use the low-level XML modules when you need to get much more out of the process and you need more flexibility than the higher-level interfaces provide.
This gets back to my standard argument that there can never be one XML (or CGI or web framework or ...) interface because there isn't just one XML task that people have to do. People tend to stick with the XML module (CGI module, web framework) that they learn first and force every task into that way of thinking. I'd like to see a Consumer Reports style guide to for these things.