Here is my updated file (simple version - as mentioned before the original file names seem to be intersposed):
For some reason the generated xml file is throwing a xml parsing error (or syntax) in Firefox:
"element not found, line:1, col:1". By the way your file is based on the simple version.
EDIT: After looking at the content of my gallery folder, I noticed that your script creates by default a file called "can_cm_sitemapxml" - the file name must be between '' (line 14). So there is no error message (the error message came because the manually created can_cm_sitemap.xml file was emtpy).
The fixed version of your file is attached as zipped to this message.