title: Iterating over child nodes in XML file with JavaScript using XPath
body: <p>Given a legacy input XML file of the form:</p>
  
  <pre><code>&lt;?xml version="1.0" ?&gt;
  &lt;data&gt;
  &lt;map&gt;
      &lt;key&gt;title&lt;/key&gt;
      &lt;string&gt;A Title Here&lt;/string&gt;
  
      &lt;key&gt;description&lt;/key&gt;
      &lt;string&gt;Description goes here&lt;/string&gt;
  
      &lt;key&gt;elements&lt;/key&gt;
  
      &lt;map&gt;
        &lt;key&gt;item1&lt;/key&gt;
        &lt;map&gt;
          &lt;key&gt;name&lt;/key&gt;
          &lt;string&gt;foo&lt;/string&gt;
          &lt;key&gt;url&lt;/key&gt;
          &lt;string&gt;http://foo.com&lt;/string&gt;
        &lt;/map&gt;
  
        &lt;key&gt;item2&lt;/key&gt;
        &lt;map&gt;
          &lt;key&gt;name&lt;/key&gt;
          &lt;string&gt;bar&lt;/string&gt;
          &lt;key&gt;url&lt;/key&gt;
          &lt;string&gt;http://bar.com&lt;/string&gt;
        &lt;/map&gt;
  
        &lt;key&gt;item3&lt;/key&gt;
        &lt;map&gt;
          &lt;key&gt;name&lt;/key&gt;
          &lt;string&gt;flasm&lt;/string&gt;
          &lt;key&gt;url&lt;/key&gt;
          &lt;string&gt;http://flasm.com&lt;/string&gt;
        &lt;/map&gt;
  
      &lt;/map&gt;
  &lt;/map&gt;
  </code></pre>
  
  <p>using Javascript, I want to find the 'elements' tag (not always in the same place) and then iterate over all its children ('item' N) and gather the key/string pairs for each (e.g. "name=foo")</p>
  
  <p>I've tried to do it a number of ways using DOMReader and Xpath but have not been able to get it quite right.</p>
  
  <p>Can anyone show me how best to do this?</p>
  
  <p>(This doesn't look like other XML I've seen so maybe that's why I'm having trouble using this in the examples I've found but as I said, it's legacy and I have no control over it).</p>
  
  <p>Many thanks.</p>