Search and replace text in XML file?

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Jul 28 10:29:12 CEST 2012


On 28/07/2012 08:17, Terry Reedy wrote:
> 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.
>

I highly recommend the use of notepad++.  If anyone knows of a better 
text editor for Windows please let me know :)

-- 
Cheers.

Mark Lawrence.




More information about the Python-list mailing list