I do not get why this works:
content = urllib2.urlopen(url)
context = etree.iterparse(content, tag='{my_ns}my_first_tag')
context = iter(context)
#for event, elem in context:
# pass
context = etree.iterparse(content, tag='{my_ns}my_second_tag')
for event, elem in context:
pass
where this doesn't work:
content = urllib2.urlopen(url)
context = etree.iterparse(content, tag='{my_ns}my_first_tag')
context = iter(context)
for event, elem in context:
pass
context = etree.iterparse(content, tag='{my_ns}my_second_tag')
for event, elem in context:
pass
and gives me this error:
XMLSyntaxError: Extra content at the end of the document, line 1, column 1
Can I not parse the same content twice? Strange that it is working when I just comment the loop and not the whole iterparse command.
Am I missing to close something?
Many thanks