def get_urlsets(self):
        if self._validate:
            schema = etree.XMLSchema(file=open(self.get_schema_path()))
        else:
            schema = None
        context = etree.iterparse(self._handle, events=('end',), schema=schema)

        location = ''
        for action, elem in context:
            tag = self._remove_ns(elem.tag)
            if tag == 'sitemap' and location:
                try:
                    yield UrlSet.from_url(location, validate=self._validate)
                except:
                    location = ''
                    continue
            elif tag == 'loc':
                location = elem.text
        del context
        del schema
Parse the xml file and generate the urlsets.
dataset/ETHPy150Open andreisavu/python-sitemap/sitemap/sitemapindex.py/SitemapIndex.get_urlsets