<p>Let's say I have an existing trivial XML file named 'MyData.xml' that contains the following:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;myElement&gt;foo&lt;/myElement&gt;
</code></pre>

<p>I want to change the text value of 'foo' to 'bar' resulting in the following:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
&lt;myElement&gt;bar&lt;/myElement&gt;
</code></pre>

<p>Once I am done, I want to save the changes.  </p>

<p>What is the easiest and simplest way to accomplish all this?</p>

For quick, non-critical XML manipulations, i really like
P4X
. It let's you write like this:
```
```
import p4x
doc = p4x.P4X (open(file).read)
doc.myElement = 'bar'
```
```