我有一个 xml 类型的文档:
<configuration>
<appSettings>
<add key="title" value="Donny" />
<add key="updaterApplication" value="Updater v4.3" />
</appSettings>
</configuration>
我需要修改一个特定的条目,例如value="Updater v4.3"to value="Updater v4.4",当 add 时key="updaterApplication"。
我试过:
import xml.etree.ElementTree as ET
tree = ET.parse(my_file_name)
root = tree.getroot()
tkr_itms = root.findall('appSettings')
for elm in tkr_itms[0]:
print(elm)
print(elm.attributes)
print(elm.value)
print(elm.text)
但无法解决'< ... />'.
有只小跳蛙
呼如林
相关分类