def resources_as_xml(self, resources, sitemapindex=False, fh=None):
        # 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 < (2,7)):
            tree.write(fh,encoding='UTF-8')
        elif (sys.version_info < (3,0)):
            tree.write(fh,encoding='UTF-8',xml_declaration=True,method='xml')
        else:
            tree.write(fh,encoding="unicode",xml_declaration=True,method='xml')
        if (xml_buf is not None):
            return(xml_buf.getvalue())


    ##### Read/parse an XML sitemap or sitemapindex #####
Write or return XML for a set of resources in sitemap format
dataset/ETHPy150Open resync/resync/resync/sitemap.py/Sitemap.resources_as_xml