Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Parapura Rajkumar
February 9, 2009, 4:00 pm
rate this thread
Re: indented xml using XML::DOM
XML::DOM doesn't seem to provide any mean of pretty printing the output.
Note that in a purely XML context, there is no need for it, and adding
whitespace indiscriminately could even lead to the output becoming invalid (wrt
That said you can always post-process your XML, using xmllint (which comes with
libxml2) or xml_pp (which comes with XML::Twig) for example.
Finally, I have to add a word of caution about XML::DOM: these days, XML::LibXML
is the preferred DOM implementation in Perl. It is a lot more powerful than
XML::DOM, and more actively maintained AFAIK. It is also quite compatible with
XML::DOM, so it is pretty easy to port the code.