Search and replace text in XML file?
tjreedy at udel.edu
Sat Jul 28 09:17:45 CEST 2012
On 7/27/2012 9:23 PM, todd.tabern at gmail.com wrote:
> I'm looking to search an entire XML file for specific text and
> replace that text, while maintaining the structure of the XML file.
For a one-off project, or for experimentation, I would use a proper
text-editor* and run through with search/replace. For automation, use
Jason's suggestion of .replace, perhaps on a line-by-line basis.
* By definition, such only make changes you request. Notepad++ is one
such on Windows. You do not want a word or document processor, or, for
simple xml oblivious text substitutions, an xml processor. Such things
often make changes of various sorts.
Terry Jan Reedy
More information about the Python-list