I have an XML like this:
<process>
<NAME source="hsfg" class="hshah" property="Name">
<VALUE type="string"></VALUE>
<VALUE type="None"></VALUE>
</NAME>
<number source="fdsg" class="hgdgf" property="gagfa">
<VALUE type="string"></VALUE>
<VALUE type="None"></VALUE>
</number>
<id source="ag" class="gfdg" property="fadg">
<VALUE type="string"></VALUE>
<VALUE type="None"></VALUE>
</id>
</process>
I would like to add the text in here <VALUE type="string"></VALUE>
I tried here but it add to all the VALUE not only in the attribute this <NAME source="hsfg" class="hshah" property="Name">
import xml.etree.ElementTree as ET
tree = ET.parse('Example.xml')
root = tree.getroot()
for elem in tree.iter('VALUE'):
elem.text = 'new value'
tree = ET.ElementTree(root)
tree.write('newitems.xml')
My expectation output like this:
<process>
<NAME source="hsfg" class="hshah" property="Name">
<VALUE type="string">new value</VALUE>
<VALUE type="None"></VALUE>
</NAME>
<number source="hsfg" class="hgdgf" property="gagfa">
<VALUE type="string"></VALUE>
<VALUE type="None"></VALUE>
</number>
<id source="hsfg" class="gfdg" property="fadg">
<VALUE type="string"></VALUE>
<VALUE type="None"></VALUE>
</id>
</process>
anyone can help, please. really thankful :)