summaryrefslogtreecommitdiff
path: root/tree.py
diff options
context:
space:
mode:
Diffstat (limited to 'tree.py')
-rw-r--r--tree.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/tree.py b/tree.py
new file mode 100644
index 0000000..efac907
--- /dev/null
+++ b/tree.py
@@ -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