Properly escape strings before writing XML.