summaryrefslogtreecommitdiff
path: root/parser.py
blob: 361abe5aa70a3c927953a35f387e44d5a0cc4bdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import xml.etree.ElementTree as ET

xmlTree = ET.parse('/home/eric/Documents/example.xml')
xmlRootTag = {elem.tag for elem in xmlTree.iter()}


#xmlTree = ET.parse('/home/fossee/Documents/example.xml')
#xmlRootTag  = list({elem.tag for elem in xmlTree.iter()})

#for xmlChild in xmlRootTag:
    #if xmlChild :
       # print(xmlChild)

for xmlChild in xmlRootTag:
    if xmlChild == 'to':
        xmlChild = 'food'
        #print(xmlChild)
    #else:
        #print(xmlChild)
xmlTree.write('/home/eric/Documents/new.xml')