

def escapeToXML(text, isattrib=False):
    'Borrowed from twisted.xish.domish\n\n    Escape text to proper XML form, per section 2.3 in the XML specification.\n\n     @type text: L{str}\n     @param text: Text to escape\n\n     @type isattrib: L{bool}\n     @param isattrib: Triggers escaping of characters necessary for use as attribute values\n    '
    text = text.replace('&', '&amp;')
    text = text.replace('<', '&lt;')
    text = text.replace('>', '&gt;')
    if isattrib:
        text = text.replace("'", '&apos;')
        text = text.replace('"', '&quot;')
    return text

dataset/ETHPy150Open twisted/nevow/nevow/util.py escapeToXML/original