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.
XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table border="2">
<tr>
<th>firstname</th>
<th>lastname</th>
<th>age</th>
</tr>
<xsl:for-each select="people/person">
<tr>
<td><span contenteditable="true"><xsl:value-of select="firstname"/></span></td>
<td><span contenteditable="true"><xsl:value-of select="lastname"/></span></td>
<td><span contenteditable="true"><xsl:value-of select="age"/></span></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
XML format I want:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="table.xsl"?>
<people>
<person>
<firstname>John</firstname>
<lastname>Johnson</lastname>
<age>20</age>
</person>
</people>
UPDATE: From here Getting value from table cell in javascript...not jquery I am now getting a list of values but they include the span tags so I am getting <span contenteditable="true">John</span>
. How do I remove the span tags so I just get "John"? Below is the JavaScript I am using.
function GetCellValues()
{
var table = document.getElementById('mytable');
for (var r = 0, n = table.rows.length; r<n; r++)
{
for (var c = 0, m = table.rows[r].cells.length; c<m; c++)
{
alert(table.rows[r].cells[c].innerHTML);
}
}
}