def escape_xml_characters(data):
  """Return copy of string with XML special characters escaped.

  This replaces the characters <, > and & with the XML escape
  sequences &lt;, &gt; and &amp;. It also replaces double
  quotes with &quot;.

  This could be replaced in future by the
  'xml.sax.saxutils.escape' function."""
  return str(data).replace("&","&amp;").replace("<","&lt;").replace(">","&gt;").replace('"',"&quot;")