мой образец xml объект:
<Assessment version="10" dateCreated="4/19/2020 10:41:20 PM">
<Section name="Space">
<Glossary>
<Item name="***"><b>Indicates high priority data that is required</b></Item>
</Glossary>
<InputNumber type="int" min="0" max="100" title="[1a] q2 some data">
<Value>20</Value>
</InputNumber>
<InputNumber type="int" min="0" max="10000" title="[2] some data">
<Value>1</Value>
</InputNumber>
<InputNumber type="int" min="0" max="10000" title="[3] some text">
<Value>2</Value>
</InputNumber>
</Section>
<Section name="Power">
<Glossary>
<Item name="***"><b>Indicates high priority data that is required</b></Item>
</Glossary>
<InputNumber type="int" min="0" max="100000" title="[8] some text">
<Value>15</Value>
</InputNumber>
<PickList title="[11] some text">
<Option selected="true">Yes</Option>
<Option>No</Option>
<Option>there is no UPS</Option>
</PickList>
</Section>
<Section name="Cooling">
<Glossary>
<Item name="***"><b>Indicates high priority data that is required</b></Item>
</Glossary>
<InputNumber type="int" min="0" max="100000" title="[18] some text">
<Value>30</Value>
</InputNumber>
</InputText>
<InputText title="[21] some data">
<Value>3</Value>
</InputText>
</Section>
<Section name="Comments">
<InputTextArea title="[22] General Comments" format="normal">
<Value>test value for capacity assessment test by monika</Value>
</InputTextArea>
</Section>
</Assessment>
я получаю это из базы данных
В моем скрипте python:
template= cursor.fetchall()
for row in template:
#xmlTemplate = ET.ElementTree(ET.fromstring(row[6]))
xmlTemplateStr = row[6]
xmlTemplate = ET.ElementTree(ET.fromstring(xmlTemplateStr))
root = ET.fromstring(xmlTemplateStr)
мне нужно найти узел по номеру и обновить значение этого перикулярного узла
, например: если нужно обновить следующее значение до 4:
</InputText>
<InputText title="[21] some data">
<Value>3</Value>
</InputText>
мне нужно найти узел с ключом [21] и обновите значение этого узла до 4
</InputText>
<InputText title="[21] some data">
<Value>4</Value>
</InputText>
Как мне это сделать?