Replace value of node using getElementsByTagName

Stefan Behnel stefan_ml at
Sun Aug 10 15:01:20 CEST 2008

Ouray Viney wrote:
> Is there an easy way to replace the node value of <ib>?  Perhaps I am
> trying to use the wrong python XML library?

Looks like it. Try ElementTree.

    from xml.etree import ElementTree
    tree = ElementTree.parse("yourfile.xml")
    for ib in tree.findall("//ib"):
        ib.text = calculate_new_value(ib.text)


More information about the Python-list mailing list