Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tag_name: str
The name of the XML tag to parse until
quit_name: str
The name to stop parsing at.
Yields
------
lxml.etree.Element
'''
g = etree.iterparse(source, ('start', 'end'))
for event, tag in g:
if event == 'start':
if xml._local_name(tag) == quit_name:
break
else:
if xml._local_name(tag) == target_name:
yield tag
else:
tag.clear()
Parameters
----------
source: file-like
A file-like object over an XML document
tag_name: str
The name of the XML tag to parse until
Returns
-------
dict
'''
g = etree.iterparse(source, ('start', 'end'))
for event, tag in g:
if event == 'start':
if xml._local_name(tag) == tag_name:
return tag.attrib
else:
continue
else:
tag.clear()
return None