Hello,
I'm creating a table dynamically from a xml using the following code
- function showData() {
- $.ajax({
- type:"GET",
- url:"test1.xml",
- dataType:"xml",
- success: function(xml){
- var fila = $(xml).find("Row");
- var tabla = $("<table />");
- tabla[0].border = "1";
-
- var row = $(tabla[0].insertRow(-1));
-
- fila.eq(0).children().each(function() {
- var headerCell = $("<th />");
- headerCell.html(this.nodeName);
- row.append(headerCell);
- });
-
- $(fila).each(function() {
- row = $(tabla[0].insertRow(-1));
- $(this).children().each(function() {
- var cell = $("<td />");
- cell.html($(this).text());
- row.append(cell);
- });
- });
-
- var dvTable = $("#dvTable");
- dvTable.html("");
- dvTable.append(tabla);
- }
-
- })
- }
It creates the table as follow
<table>
<tbody>
<tr>
<th>...</th>
....
</tr>
<tr>
<td...</td>
...
<t/tr>
...
</tbody>
</table>
How can I make it so that it creates the THEAD tag before the TBODY and add the TH columns inside the THEAD??
Any help would be greatly appreciated.
Thanks