def METHOD_NAME(self, attribute):
    # Escape XML characters in attributes.
    try:
        if not self.escapes.search(attribute):
            return attribute
    except TypeError:
        return attribute
    attribute = (
        attribute.replace("&", "&amp;")
        .replace('"', "&quot;")
        .replace("<", "&lt;")
        .replace(">", "&gt;")
        .replace("\n", "&#xA;")
    )
    return attribute