print('Size of list = ' + str(len(name_list)))

def bench_lxml_getiterator(tree):
    result = []
for name in tree.getiterator('name'):
    result.append(name.text)
print('Size of list = ' + str(len(result)))

def bench_lxml_findall(tree):
    result = []
for name in tree.findall('//name'):
    result.append(name.text)
print('Size of list = ' + str(len(result)))
Быстрый XML-валидатор Python с поддержкой XPath