added generic toXML code