Greetings I want to take part of a word remove it and then append something new. Here is my xml
<Symbols>
<Item>
<Symbol>UPS2008</Symbol>
<Order>usg_05Y</Order>
</Item>
</Symbols>
My python code should remove the 2008 in UPS and change it to 2009 (basically write to file with elementtree), except I do not know what is up with my code. Any help would be appreciated and yes I read the effbot site but I must be doing something wierd. Thank you.
import urllib
import sys, string, os, datetime
import xml.etree.ElementTree as ET
root=ET.parse("thefile").getroot()
iter=root.getiterator('Item')
print iter
for n in iter :
symbol=n.findtext('Symbol')
print symbol
if 'USP' in symbol:
nodes=symbol[3:7]
n.remove(nodes)
n.append('2009')
print "done"
Thanks