def lxml_trace(data, html=True, **kwargs):
 from lxml import etree
 for (event, element) in etree.iterparse(StringIO(data), html=html, **kwargs):
  print ('%s, %4s, %s' % (event, element.tag, element.text))

def lxml_trace ( data , html = True , ** kwargs ) : from lxml import etree for ( event , element ) in etree . iterparse ( StringIO ( data ) , html = html , ** kwargs ) : print ( '%s, %4s, %s' % ( event , element . tag , element . text ) )
print out the lxml events that occur during parsing .