I have to wonder if mirod would take offense at implying that XML::Twig is less reliable than other choices ;-)
For something this small, XML::Twig may be overkill. But for the project we're working on at work, "just us[ing] print()" is actually less reliable. Finding and quashing close-tag errors in a multi-MB XML file is painful. Using a module, such as XML::Twig, helps to avoid these errors.
And writing a "toXML" function is exactly the same problem that the OP had - just not objectified. For these, I, personally, would still want to rely on an XML module to handle things for me.
Just my opinion... :-)
|