While trying to parse an xml file into table format, jQuery keeps closing my opening <tr>
tag. Is there a work around for this?
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
type: "GET",
url: "sample-data.xml",
dataType: "xml",
success: parseXml
});
});
function parseXml(xml)
{
$(xml).find("user").each(function()
{
var id = "#sortable";
$(id).append("<tr>");
$(id).append("<td>" + $(this).find("name").text() + "</td>");
$(id).append("</tr>");
});
}
</script>
<table id="table" class="tablesorter">
<thead>
<tr>
<th>test</th>
</tr>
</thead>
<tbody id="sortable">
</tbody>
</table>
This is how the markup is being outputted:
<tr></tr>
<td>data</td>
Yeah, jQuery doesn't really work that. Try this: