Write or return XML for a set of resources in sitemap format.

        Arguments:
        - resources - either an iterable or iterator of Resource objects;
                      if there an md attribute this will go to <rs:md>
                      if there an ln attribute this will go to <rs:ln>
        - sitemapindex - set True to write sitemapindex instead of sitemap
        - fh - write to filehandle fh instead of returning string

def resources_as_xml(self, resources, sitemapindex=False, fh=None):
        """Write or return XML for a set of resources in sitemap format.

        Arguments:
        - resources - either an iterable or iterator of Resource objects;
                      if there an md attribute this will go to <rs:md>
                      if there an ln attribute this will go to <rs:ln>
        - sitemapindex - set True to write sitemapindex instead of sitemap
        - fh - write to filehandle fh instead of returning string
        """
        # element names depending on sitemapindex or not
        root_element = ('sitemapindex' if (sitemapindex) else 'urlset')
        item_element = ('sitemap' if (sitemapindex) else 'url')
        # namespaces and other settings
        namespaces = {'xmlns': SITEMAP_NS, 'xmlns:rs': RS_NS}
        root = Element(root_element, namespaces)
        if (self.pretty_xml):
            root.text = "\n"
        # <rs:ln>
        if (hasattr(resources, 'ln')):
            for ln in resources.ln:
                self.add_element_with_atts_to_etree(root, 'rs:ln', ln)
        # <rs:md>
        if (hasattr(resources, 'md')):
            self.add_element_with_atts_to_etree(root, 'rs:md', resources.md)
        # <url> entries from either an iterable or an iterator
        for r in resources:
            e = self.resource_etree_element(r, element_name=item_element)
            root.append(e)
        # have tree, now serialize
        tree = ElementTree(root)
        xml_buf = None
        if (fh is None):
            xml_buf = io.StringIO()
            fh = xml_buf
        if (sys.version_info >= (3, 0)):
            tree.write(
                fh,
                encoding='unicode',
                xml_declaration=True,
                method='xml')
        elif (sys.version_info >= (2, 7)):
            tree.write(
                fh,
                encoding='UTF-8',
                xml_declaration=True,
                method='xml')
        else:  # python2.6
            tree.write(fh, encoding='UTF-8')
        if (xml_buf is not None):
            if (sys.version_info >= (3, 0)):
                return(xml_buf.getvalue())
            else:
                return(xml_buf.getvalue().decode('utf-8'))