tags:

views:

56

answers:

1
<example>
    <login>
        <id>1</id>
        <username>kites</username>
        <password>kites</password>
    </login>
</example>

How can i update password using lxml? and now can i add one more record to the same file?

please provide me a sample code

+1  A: 
example = etree.Element("example")
login = etree.SubElement(example, "login")
password = etree.SubElement(login,"password")
password.text = "newPassword"

This is a good tutorial

Svetlozar Angelov
after this we need to call etree.write(filepath)make make effect in xml filei have found another tutorial which i think is betterhttp://infohost.nmt.edu/tcc/help/pubs/pylxml/
RSK