Updated the writeXML to work with topics.