'Returns an XML-encoded representation of the error.
Returns:
str: An XML document for the error.'

def to_xml(self):

    error_element = et.Element('error')
    et.SubElement(error_element, 'title').text = self.title
    if (self.description is not None):
        et.SubElement(error_element, 'description').text = self.description
    if (self.code is not None):
        et.SubElement(error_element, 'code').text = str(self.code)
    if (self.link is not None):
        link_element = et.SubElement(error_element, 'link')
        for key in ('text', 'href', 'rel'):
            et.SubElement(link_element, key).text = self.link[key]
    return ('<?xml    version="1.0"    encoding="UTF-8"?>' + et.tostring(error_element, encoding='utf-8'))
