I am trying to parse some xml which is in the following format:
<label>
<name></name>
<sometag></sometag>
<sublabels>
<label></label>
<label></label>
</sublabel>
</label>
Parsing it with this
for event, element in etree.iterparse(gzip.GzipFile(f), events=('end', ), tag='label'):
if event == 'end':
name = element.xpath('name/text()')
produces empty name variable because of the
<sublabels>
<label></label>
<label></label>
</sublabel>
The question:
Is there any way to set the depth of the iterparse or ignore the sublabel label other than checking if it is empty?