I have an xml file as such:
<root processName="someName" >
<Property name="FirstProp" value="one" />
<Property name="SecondProp" value="two" />
<Property name="ThirdProp" value="three" />
</root>
Is it possible, using xmltodict, to find the Property "SecondProp" without knowing the specific index and change value from "two" to "seventeen"? (below)
Code:
import os
import xmltodict
text_file = open("testxml.xml", "r")
tst = text_file.read()
obj = xmltodict.parse(tst)
print(obj['root']['@processName'])
print(obj['root']['Property'][0])
print(obj['root']['Property'][1])
print(obj['root']['Property'][2])
Output:
someName
OrderedDict([('@name', 'FirstProp'), ('@value', 'one')])
OrderedDict([('@name', 'SecondProp'), ('@value', 'two')])
OrderedDict([('@name', 'ThirdProp'), ('@value', 'three')])