import xml.etree.ElementTree as ET
file_name='a.xml'
root=ET.parse(file_name).getroot()
f2 = open('b.txt','r+')
aa=''
for i in root.iter('ArchiveHeader'):
for j in i:
for k in j:
aa=aa+k.text
f2.write('\r\n')
for i in root.iter('DataGram'):
print('\r\n')
for j in i:
for k in j:
if k.text==None:
pass
else:
if k.tag=='PAYERBANK':
print ('aa')
bb=k.text
print('|')
aa=bb+'|'
aa=''
f2.close()
for i in root.iter('ArchiveHeader'):
for j in i:
for k in j:
aa=aa+k.text
f2.write('\r\n')
for i in root.iter('DataGram'):
#print('\r\n')
for j in i:
for k in j:
if k.text==None:
pass
else:
#if k.tag=='PAYERBANK':
# print ('aa')
# bb=k.text
aa=aa+k.text
aa=aa+'|'
f2.write(aa)
f2.write('\r\n')