求读取 中数据的算法

lpc007 2009-03-17 06:41:31

<table ................>
<tr>
<td>11111</td>
<td>22222</td>
</tr>
<tr>
<td>333</td>
<td>444444</td>
</tr>
<tr>
<td>5555</td>
<td>66666666</td>
</tr>
</table>


如上代码,我现在要读取出<td></td>之间的数据,有什么好的办法?

...全文
129 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
gisyellow 2009-03-17
  • 打赏
  • 举报
回复
XML更方便啊。
yinxiaowei823 2009-03-17
  • 打赏
  • 举报
回复
楼上大家说的对的

简单写了一下
System.Net.WebClient wc = new System.Net.WebClient();
string sourceString = wc.DownloadString(URL);

// tb间内容
string tbString = "";


System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(sourceString, @"(?<=<td>)[\s\S]*?(?=</td>)", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
for (int i = 0; i < mc.Count; i++)
{
tbString += mc[i].Value + ";";
}


gui0605 2009-03-17
  • 打赏
  • 举报
回复
这个一个正则就匹配出来了
(?<=<td>)(.*)(?=</td>)
wuyq11 2009-03-17
  • 打赏
  • 举报
回复
飞天鹰 2009-03-17
  • 打赏
  • 举报
回复
我也觉得用xml文件最好,方便好用
深海之蓝 2009-03-17
  • 打赏
  • 举报
回复
还是存成xml文件 然后再通过相应的方法 读出节点的数据,感觉要容易很多
lpc007 2009-03-17
  • 打赏
  • 举报
回复
求正则表达式~~~
  • 打赏
  • 举报
回复
WebClient 获取网页的源文件
通过正则切割

110,566

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

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