summaryrefslogtreecommitdiff
path: root/tree.py
blob: efac907e98aaf420cdd0c845fe1919b24405b87a (plain)
1
2
3
4
5
6
7
8
9
10
import xml.etree.ElementTree as ET
tree = ET.parse('/home/eric/Documents/example.xml')
root = tree.getroot()
for rank in root.iter('rank'):
    new_rank=int(rank.text) + 2
    rank.text = str(new_rank)
    rank.set('updated','yes')
tree.find('.//year').text = '1/1/2011'

tree.write('/home/eric/Documents/new.xml')