How to populate xml file using xpath in Python
<p>I have an xpath for a node in an xml file which does not yet exist, and want to use it to generate the node in question.  I've started work on a function to do this but was wondering if there's an existing library which can do it and save me some time?  I'm currently working with pyxml but am considering porting it to ElementTree.  So to clarify I want :</p>

<pre><code>root/foo/bar
</code></pre>

<p>to produce:</p>

<pre><code>&lt;root&gt;
  &lt;foo&gt;
    &lt;bar&gt;
    &lt;/bar&gt;
  &lt;/foo&gt;
&lt;/root&gt;
</code></pre>

<p>My suspicion is that the behaviour of such a function is not well enough defined for the general case for anyone to have bothered but thought I'd throw it out there just in case.  I have a DTD for the file as well if that would help. </p>
