I'm writing a Python script in which I need to do some search and replace in some XML-like strings.
Let's say I have a string foo
that contains some XML of the form <bar>something</bar>
. I want to change the something
within the <bar>...</bar>
, let's say to <bar>something_else</bar>
.
How would I go about doing this?
Sorry if this is a newbie question, but I'm pretty new to Python. I read through the Python regular expression docs but that only served to confuse me further. (actually I find regular expressions confusing in other contexts/languages as well, so that may not necessarily be Python's fault :) )