in reply to compacting XML?

XML::Tidy has a function, strip(), that does exactly what you have requested.

strip()

The strip() member function searches the Tidy object for all mixed-content (i.e., non-data) text nodes && empties them out. This will basically unformat any markup indenting.

strip() is used by compress() && tidy() but it is exposed because it could be worthwhile by itself.