This was ugly having this method do the XML gen and then half of the encoding. I moved all the encoding out.