I have a very large (1.8GB) XML document. I'd like to simply find the number of elements with the tag <Product>
.
I've got this far:
context = etree.iterparse('./test.xml', tag='Product')
num_elems = 0
for event, elem in context:
num_elems += 1
print num_elems
It works, but is there a faster way of doing it?