more work on write out functions for handleXML