I had to roll my own commands to do something similar. Given an input file of commands to run, I had to catch the stdout, stderr and return value of each command which I then wrapped in XML tags and put in a logfile. Got a very ugly script at the end of it, but also had XML files that more sophisticated programs could work on.
Whilst shell scripting one-liners can do a lot of work easily, I think trying to build larger applications falls down precisely because there isn't a code repository and modules like CPAN.
A difficult part was trying to keep program logic seperate from all the echo commands, which you seem to be doing by abstracting out the echos into functions. Makes it easier to generate a syntactically correct xml file, too. Then you have the problem of getting a DTD from the program logic.