title: How to use javascript regular expression to change xml structure?
body: <p>could any one show me how i can use JavaScript regular expression to change following xml structure ?</p>
  
  <p><strong>default xml</strong></p>
  
  <pre><code>    &lt;dict&gt;
      &lt;key&gt;TITLE&lt;/key&gt;
      &lt;string&gt;first&lt;/string&gt;
      &lt;key&gt;URL&lt;/key&gt;
      &lt;string&gt;http://someurl.com/1.m3u8&lt;/string&gt;
      &lt;/dict&gt;
      &lt;dict&gt;
      &lt;key&gt;TITLE&lt;/key&gt;
      &lt;string&gt;Second&lt;/string&gt;
      &lt;key&gt;URL&lt;/key&gt;
      &lt;string&gt;http://someurl.com/2.m3u8&lt;/string&gt;
      &lt;/dict&gt;
      &lt;dict&gt;
      &lt;key&gt;TITLE&lt;/key&gt;
      &lt;string&gt;Third&lt;/string&gt;
      &lt;key&gt;URL&lt;/key&gt;
      &lt;string&gt;http://someurl.com/3.m3u8&lt;/string&gt;
      &lt;/dict&gt;
  </code></pre>
  
  <p><strong>convert to :</strong></p>
  
  <pre><code>    &lt;dict&gt;
      &lt;url&gt;http://someurl.com/1.m3u8&lt;/url&gt;
      &lt;title&gt;First&lt;/title&gt;
      &lt;/dict&gt;
      &lt;dict&gt;
      &lt;url&gt;http://someurl.com/2.m3u8&lt;/url&gt;
      &lt;title&gt;Second&lt;/title&gt;
      &lt;/dict&gt;
      &lt;dict&gt;
      &lt;url&gt;http://someurl.com/3.m3u8&lt;/url&gt;
      &lt;title&gt;Third&lt;/title&gt;
      &lt;/dict&gt;
  </code></pre>
  
  <p><strong>Edit:</strong> i want to parse converted xml using this code:</p>
  
  <pre><code>&lt;button type="button" onclick="loadXMLDoc()"&gt;crate table&lt;/button&gt;
  &lt;br&gt;&lt;br&gt;
  &lt;table id="demo"&gt;&lt;/table&gt;
  
  &lt;script&gt;
  function loadXMLDoc() {
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (this.readyState == 4 &amp;&amp; this.status == 200) {
        myFunction(this);
      }
    };
    xmlhttp.open("GET", "myxml.xml", true);
    xmlhttp.send();
  }
  function myFunction(xml) {
    var i;
    var xmlDoc = xml.responseXML;
    var table="&lt;tr&gt;&lt;th&gt;URL&lt;/th&gt;&lt;th&gt;Title&lt;/th&gt;&lt;/tr&gt;";
    var x = xmlDoc.getElementsByTagName("dict");
    for (i = 0; i &lt;x.length; i++) { 
      table += "&lt;tr&gt;&lt;td&gt;" +
      x[i].getElementsByTagName("url")[0].childNodes[0].nodeValue +
      "&lt;/td&gt;&lt;td&gt;" +
      x[i].getElementsByTagName("title")[0].childNodes[0].nodeValue +
      "&lt;/td&gt;&lt;/tr&gt;";
    }
    document.getElementById("demo").innerHTML = table;
  }
  &lt;/script&gt;
  </code></pre>