I could read the content of the xml file to a string and use string operations to achieve this, but I guess there is a more elegant way to do this. Since I did not find a clue i
If you want to count all author tags:
import lxml.etree doc = lxml.etree.parse(xml) count = doc.xpath('count(//author)')