xml ファイルをテーブル形式に解析しようとすると、jQuery は開始<tr>
タグを閉じ続けます。これに対する回避策はありますか?
<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>
これは、マークアップが出力されている方法です。
<tr></tr>
<td>data</td>