<s> """<STR_LIT>""" <EOL> from lxml import etree <EOL> context = etree . iterparse ( "<STR_LIT>" ) <EOL> for action , elem in context : <EOL> if elem . tag == "<STR_LIT>" : <EOL> print "<STR_LIT>" <EOL> if elem . text . strip ( ) : <EOL> print ( "<STR_LIT>" % ( action , elem . tag , elem . text ) ) <EOL> parser = etree . XMLParser ( remove_blank_text = True ) <EOL> tree = etree . parse ( "<STR_LIT>" , parser ) <EOL> resources = tree . getroot ( ) <EOL> new_resource = etree . SubElement ( resources , "<STR_LIT>" ) <EOL> new_resource_name = etree . SubElement ( new_resource , "<STR_LIT:name>" ) <EOL> new_resource_name . text = "<STR_LIT>" <EOL> new_resource_temperature = etree . SubElement ( new_resource , "<STR_LIT>" ) <EOL> new_resource_temperature . text = "<STR_LIT>" <EOL> new_resource_temperature_scale = etree . SubElement ( new_resource , "<STR_LIT>" ) <EOL> new_resource_temperature_scale . text = "<STR_LIT>" <EOL> tree . write ( "<STR_LIT>" , pretty_print = True ) </s>
