开发者

How to update xml file using lxml and python?

开发者 https://www.devze.com 2022-12-17 11:21 出处:网络
<example> <login> <id>1</id> <username>kites</username> <password>kites</password>
<example>
    <login>
        <id>1</id>
        <username>kites</username>
        <password>kites</password>
    </login>
</example>

How can i update p开发者_如何学运维assword using lxml? and now can i add one more record to the same file?

please provide me a sample code


example = etree.Element("example")
login = etree.SubElement(example, "login")
password = etree.SubElement(login,"password")
password.text = "newPassword"

This is a good tutorial

0

精彩评论

暂无评论...
验证码 换一张
取 消