title: Creating XML file from HTML table?
body: <p>Currently I have a XML file and XSL file. The XSL file takes the XML file and creates an editable table in HTML. What I need to do now is to be able to click on a button and the table values are saved in a new XML file. What is the best method for doing this? It seems PHP would be good for making the XML file but have no idea how to get the values from a XSL made table. Preferably I would like to do it with XSL but if not JavaScript or PHP. If someone could point me in the right direction, even just by telling me which language can do this I would be very thankful.</p>
  
  <p>XSL:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:template match="/"&gt;
  &lt;html&gt;
  &lt;body&gt;
      &lt;table border="2"&gt;
          &lt;tr&gt;
              &lt;th&gt;firstname&lt;/th&gt;
              &lt;th&gt;lastname&lt;/th&gt;
              &lt;th&gt;age&lt;/th&gt;
          &lt;/tr&gt;
  
          &lt;xsl:for-each select="people/person"&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;span contenteditable="true"&gt;&lt;xsl:value-of select="firstname"/&gt;&lt;/span&gt;&lt;/td&gt;         
              &lt;td&gt;&lt;span contenteditable="true"&gt;&lt;xsl:value-of select="lastname"/&gt;&lt;/span&gt;&lt;/td&gt;
            &lt;td&gt;&lt;span contenteditable="true"&gt;&lt;xsl:value-of select="age"/&gt;&lt;/span&gt;&lt;/td&gt;
  
  
          &lt;/tr&gt;
          &lt;/xsl:for-each&gt;
      &lt;/table&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>XML format I want:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="table.xsl"?&gt;
  &lt;people&gt;
      &lt;person&gt;
          &lt;firstname&gt;John&lt;/firstname&gt;
          &lt;lastname&gt;Johnson&lt;/lastname&gt;
          &lt;age&gt;20&lt;/age&gt;
      &lt;/person&gt;   
  &lt;/people&gt;
  </code></pre>
  
  <p>UPDATE: From here <a href="https://stackoverflow.com/questions/3072233/getting-value-from-table-cell-in-javascript-not-jquery">Getting value from table cell in javascript...not jquery</a> I am now getting a list of values but they include the span tags so I am getting <code>&lt;span contenteditable="true"&gt;John&lt;/span&gt;</code>. How do I remove the span tags so I just get "John"? Below is the JavaScript I am using.</p>
  
  <pre><code>function GetCellValues()
  {
      var table = document.getElementById('mytable');
      for (var r = 0, n = table.rows.length; r&amp;lt;n; r++)
      {
          for (var c = 0, m = table.rows[r].cells.length; c&amp;lt;m; c++)
          {
              alert(table.rows[r].cells[c].innerHTML);
          }
      }
  }
  </code></pre>