#! /usr/bin/python
import xml.etree.ElementTree as ET
tree = ET.parse('avito_data.xml')
root = tree.getroot()
for e in root.findall('.//div[@class="item-views"]'):
if e.find('span') is not None:
print e.text + e.find('span').text
else:
print e.text
<?xml version="1.0"?>
<html>
<body>
<div id="root">
<div class="g_30 g_eof">
<div class="item-views"><!--noindex-->Просмотров: всего 20, сегодня 20<!--/noindex--></div>
</div>
<div class="g_30 g_eof">
<div class="item-views"><!--noindex-->Просмотров: <span class="js-show-stat pseudo-link" data-config='{ "type": "item", "url": "/items/stat/562148872" }'>всего 170, сегодня 13</span><!--/noindex--></div>
</div>
</div>
</body>
</html>
<code>