title: How to edit xml/dom with Emacs Lisp
body: <p>How can I, if possible at all, programmatically edit xml data in Emacs Lisp?</p>
  
  <p>What I need to do, is to programmatically add new nodes into arbitrary locations in the xml:</p>
  
  <pre><code>&lt;root&gt;
    &lt;child&gt;
    &lt;/child&gt;
  &lt;/root&gt;
  
  (xml-add-element xml "hello" (xml-element-by-tagname xml "child"))
  
  &lt;root&gt;
    &lt;child&gt;
      &lt;hello&gt;&lt;/hello&gt;
    &lt;/child&gt;
  &lt;/root&gt;
  </code></pre>
  
  <hr>
  
  <p><strong>Edit:</strong> I got as far as parsing the xml into a lisp structure and editing it with <code>xml.el</code> and <code>dom.el</code>, but now I need to turn the lisp structure <strong>back into xml data</strong>.</p>