def text_length(tree):
 total = 0
 for node in tree.getiterator():
  if node.text:
   total += len(node.text.strip())
  if node.tail:
   total += len(node.tail.strip())
 return total

def text_length ( tree ) : total = 0 for node in tree . getiterator ( ) : if node . text : total += len ( node . text . strip ( ) ) if node . tail : total += len ( node . tail . strip ( ) ) return total
find the length of the text content .