def get_urls_from_handle(self):
        """ Parse the xml file and generate the elements """
        if self._validate:
            schema = etree.XMLSchema(file=open(self.get_schema_path()))
        else:
            schema = None
        context = etree.iterparse(self._handle, events=('end',), schema=schema)

        element_data = {}
        for action, elem in context:
            tag = self._remove_ns(elem.tag)
            if tag == 'url' and element_data:
                try:
                    e = UrlSetElement(**element_data)
                    yield e
                except ValueError:
                    element_data = {}
                    continue
            elif tag in ['loc', 'lastmod', 'changefreq', 'priority']:
                element_data[tag] = elem.text
            while elem.getprevious() is not None:
                del elem.getparent()[0]
        del context
        del schema
dataset/ETHPy150Open andreisavu/python-sitemap/sitemap/urlset.py/UrlSet.get_urls_from_handle/original