diff options
Diffstat (limited to 'tree.py')
-rw-r--r-- | tree.py | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -0,0 +1,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')
\ No newline at end of file |