<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def resource_as_xml(self, resource):
 """Return string for the resource as part of an XML sitemap. Returns a string with the XML snippet representing the resource, without any XML declaration. """

        e = self.resource_etree_element(resource)
        if (sys.version_info >= (3, 0)):
            # python3.x
            return(tostring(e, encoding='unicode', method='xml'))
        elif (sys.version_info >= (2, 7)):
            s = tostring(e, encoding='UTF-8', method='xml')
        else:
            # must not specify method='xml' in python2.6
            s = tostring(e, encoding='UTF-8')
        # Chop off XML declaration that is added in 2.x... sigh
        return(s.replace("<?xml version='1.0' encoding='UTF-8'?>\n", ''))