This is the xml file type , I am trying modify elements in
Assume xml file name is "t.xml"
I used element tree to modify it via python and get the elements where I can modify using the logic and do it in bulk
I tried to print the names to check whether its working or not , but I am not able to get any output even though the python file is getting executed.
How can I modify c3 value in custom ???
<breakfast_menu>
<food>
<name itemid="11">Belgian Waffles</name>
<price>5.95</price>
<description>Two of our famous Belgian Waffles
with plenty of real maple syrup</description>
<calories>650</calories>
<city></city>
<state></state>
<custom>
<c1>11</c1>
<c2>ee</c2>
<c3>king</c3>
</custom>
</food>
<food>
<name itemid="21">Strawberry Belgian Waffles</name>
<price>7.95</price>
<description>Light Belgian waffles covered
with strawberries and whipped cream</description>
<calories>900</calories>
<city></city>
<state></state>
<custom>
<c1>12</c1>
<c2>ff</c2>
<c3>bye</c3>
</custom>
</food>
<food>
<name itemid="31">Berry-Berry Belgian Waffles</name>
<price>8.95</price>
<description>Light Belgian waffles covered with
an assortment of fresh berries and whipped cream</description>
<calories>900</calories>
<city></city>
<state></state>
<custom>
<c1>13</c1>
<c2>gg</c2>
<c3>getin</c3>
</custom>
</food>
<food>
<name itemid="41">French Toast</name>
<price>4.50</price>
<description>Thick slices made from our
homemade sourdough bread</description>
<calories>600</calories>
<city></city>
<state></state>
<custom>
<c1>15</c1>
<c2>hh</c2>
<c3>python</c3>
</custom>
</food>
</breakfast_menu>
import xml.etree.ElementTree as ET
mytree = ET.parse('t.xml')
myroot = mytree.getroot()
for x in myroot.findall('food'):
item = x.find('name').text
print(item)
Please provide guidance
Thanks