如何保存html内容到后台数据库?

f56_2000 2009-01-05 11:03:55
html的内容如下:
<table>
<tr>
<td>aaa</td>
<td>bbb</td>
</tr>
</table>
<table>
<tr>
<td>ccc</td>
</tr>
</table>
请问如何把aaa、bbb、ccc提取出来并保存到后台的sql数据库呢?
...全文
247 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
燥动的心 2009-01-05
  • 打赏
  • 举报
回复
mark
xuyiazl 2009-01-05
  • 打赏
  • 举报
回复
String.prototype.htmlEncode = function() {
return this.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\"/g, """).replace(/\'/g, "'");
}


string htmlvalue = document.getElmentById("aaa").innerHTML.htmlEncode();






Request.Form["td1"];
tautaulee 2009-01-05
  • 打赏
  • 举报
回复
UP```楼上已有正确答案咯```
wuhan_dotnet 2009-01-05
  • 打赏
  • 举报
回复
UP```楼上已有正确答案咯```
jiang_jiajia10 2009-01-05
  • 打赏
  • 举报
回复

<table>
<tr>
<td id="aaa">aaa </td>
<td id="bbb">bbb </td>
</tr>
</table>
<table>
<tr>
<td id="ccc">ccc </td>
</tr>
</table>
<input type="hidden" id="td1" name="td1"/>
<input type="hidden" id="td2" name="td2"/>
<input type="hidden" id="td3" name="td3"/>


document.getElementById("td1").value = document.getElmentById("aaa").innerHTML
document.getElementById("td2").value = document.getElmentById("bbb").innerHTML
document.getElementById("td3").value = document.getElmentById("ccc").innerHTML

后台
Request.Form["td1"]
Request.Form["td2"]
Request.Form["td3"]
路人乙e 2009-01-05
  • 打赏
  • 举报
回复
string html = "...";//内容略
Regex reg = new Regex("<td>.+?</td>");
Match mat = reg.Match(html);
string str = "";
while(mat.Success)
{
str += mat.Value.Substring(4, mat.Length-9);
mat = reg.Match(html, mat.Index+mat.Length);
}
//保存str

62,268

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧