【发布时间】:2012-11-29 11:50:39
【问题描述】:
我正在尝试创建一个网页来创建小型播放列表。将数据输入字段后,需要将其保存到 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。
【问题讨论】:
-
我已经编辑了你的标题。请参阅“Should questions include “tags” in their titles?”,其中的共识是“不,他们不应该”。
-
请考虑选择以下答案之一作为正确答案,或提供更多详细信息,以便我们提供进一步的帮助。
标签: c# html .net xml html-table