小さなプレイリストを作成するための Web ページを作成しようとしています。データがフィールドに入力されたら、XML ファイルに保存する必要があります。現在、表は次のようになっています。
<%-- song list table --%>
<table runat="server" id="table" class="table">
<%-- info row --%>
<thead>
<tr>
<td>Song Title</td>
<td>Song Artist</td>
<td>Song Album</td>
<td><%-- column for delete button --%></td>
</tr>
</thead>
<%-- input rows --%>
<tbody>
<tr>
<td><input runat="server" placeholder="Title" type="text" /></td>
<td><input runat="server" placeholder="Artist" type="text" /></td>
<td><input runat="server" placeholder="Album" type="text" /></td>
<td>
<a href="#">
<img src="Images/Delete.png" onmouseover="this.src='Images/Delete-Hover.png'" onmouseout="this.src='Images/Delete.png'" alt="Delete" />
</a>
</td>
</tr>
</tbody>
</table>
新しい行は jQuery で動的に追加されます。ユーザーが [保存] をクリックしたら、テーブル データを特定の XML ファイルに書き込む必要があります。現在、私のバックエンド コードは次のようになっています。
//for each row
foreach (HtmlTableRow row in table.Rows)
{
//create row info
textWriter.WriteStartElement("Row");
//for each cell
foreach (HtmlTableCell element in row.Cells)
{
//get inputs
//write current input to xml
}
//close row
textWriter.WriteEndElement();
}
私の質問は、各入力の値を取得して XML に書き込むことができるように、コードを使用してそこからどこへ行くかです。