import lxml.etree as ettree = 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)
import lxml.etree as ettree = 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)