from lxml import objectify, etree root = etree.fromstring(\'\'\'
import lxml.etree as et tree = et.fromstring(''' ... your xml ... ''') for host_ip in tree.xpath("/scenario/init/send/command[@name='CER']/avp[@name='Host-IP-Address']"): host_ip.attrib['value'] = 'foo' print et.tostring(tree)