How to update the text of a tag in XML using Elementree
- by Christopher
Using elementree, the easiest way to read the text of a tag is to do the following:
import elementtree.ElementTree as ET
sKeyMap = ET.parse("KeyMaps/KeyMap_Checklist.xml")
host = sKeyMap.findtext("/BrowserInformation/BrowserSetup/host")
Now I want to update the text in the same file, hopefully without having to re-write it with something easy like:
host = "4444"
sKeyMap.replacetext("/BrowserInformation/BrowserSetup/host")
Any ideas?
Thx in advance
Christopher