nexti None for in open some xml if page in write close elif page in ne

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
nexti = 0
f = None
for x in open("some.xml","r"):
if '</page>' in x:
f.write(x)
f.close()
elif '<page>' in x:
nexti+=1
f = open('t%d.xml'%(nexti,),"w")
f.write(x)
else:
f.write(x)