def escapeOnce(data):
    """Ensure XML output is escaped just once, irrespective of input

    >>> escapeOnce('A & B')
    'A &amp; B'
    >>> escapeOnce('C &amp; D')
    'C &amp; D'
    >>> escapeOnce('E &amp;amp; F')
    'E &amp; F'

    """
    data = data.replace('&', '&amp;')
    data = data.replace('&amp;amp;', '&amp;')
    data = data.replace('&amp;gt;', '&gt;')
    data = data.replace('&amp;lt;', '&lt;')
    data = data.replace('&amp;#', '&#')
    data = data.replace('&amp;amp;', '&amp;')
    data = data.replace('&amp;gt;', '&gt;')
    data = data.replace('&amp;lt;', '&lt;')
    return data
