pandoc is a free open source software for converting documents from many filetypes to many filetypes. For details, see http://johnmacfarlane.net/pandoc/.
Credit: the code in this function is based on GERGELY DAROCZIs coding in his answer on the Q&A forum StackOverflow, and also G. Grothendieck for the non-XML addition to the function.
I thank them both!