求一正则,大神快来

yongchaochu 2016-09-28 04:54:41

<div class='reposts'>
<div class='repost clearfix'>
<div class='left content'>
<p>
<a class='fbold nickname' href=\"http://weibo.com/xymn2008\" target=\"_blank\">驴仔奎尼动漫</a>
<span>#丝绸之路# BB.C今年出了一个丝绸之路的纪录片
<a href='http://t.cn/Rc1lC8J' target='_blank'>http://t.cn/Rc1lC8J</a>.
</span>
</p>
<div style='color:#FF6600; text-align:right;' class='mt10 clearfix'>
<span class='time left' style='_margin-left:3px;'>
<span style=\"color:#777\">默认转发理由:</span>
<input id=\"set_reason_4024714399720341\" type=\"text\" style=\"color:#888;border:0px;width:370px;*width:360px;\" value=\"\" readonly=\"readonly\" />
</span>
<span class='right'>
<a id=\"repost_btn_4024714399720341\" class='btn btn-primary' href='javascript:;' style='padding:2px 20px;'>详转</a>\t\t\t\t\t\t\t\t    \r\n\t\t\t\t\t\t\t\t
<a id=\"fast_repost_btn_4024714399720341\" class='btn btn-primary' href='javascript:;' style='padding:2px 20px;'>快转</a>\t\t\t\t\t\t\t\t 可获得77分\r\n\t\t\t\t\t\t\t
</span>
</div>
</div>
</div>
<div class='repost clearfix'>
<div class='left content'>
<p>
<a class='fbold nickname' href=\"http://weibo.com/jiaodudingzhi\" target=\"_blank\">角度订制</a>
<span>10年专注手工鞋订制。</span>
</p>
<img src=\"http://ww3.sinaimg.cn/thumbnail/005OyYofjw1f4ww93jq8wj30hi09udhg.jpg\"/>
<div style='color:#FF6600; text-align:right;' class='mt10 clearfix'>
<span class='time left' style='_margin-left:3px;'>
<span style=\"color:#777\">默认转发理由:</span>
<input id=\"set_reason_3986952569065669\" type=\"text\" style=\"color:#888;border:0px;width:370px;*width:360px;\" value=\"\" readonly=\"readonly\" />
</span>
<span class='right'>
<a id=\"repost_btn_3986952569065669\" class='btn btn-primary' href='javascript:;' style='padding:2px 14px;' need_comment='1'>详转
<i class=\"icon-comment icon-white\"></i>
</a>\t\t\t\t\t\t\t\t    \r\n\t\t\t\t\t\t\t\t
<a id=\"fast_repost_btn_3986952569065669\" class='btn btn-primary' href='javascript:;' style='padding:2px 20px;'>快转</a>\t\t\t\t\t\t\t\t 可获得77分\r\n\t\t\t\t\t\t\t
</span>
</div>
</div>
</div>
</div>


如上图的xml,我想获取每个节点里的
<a id=\"fast_repost_btn_4024714399720341\" class='btn btn-primary' href='javascript:;' style='padding:2px 20px;'>快转</a>\t\t\t\t\t\t\t\t 可获得77分\r\n\t\t\t\t\t\t\t
这段内容里的a标签的id,和可获得77分里的77分,然后得到一个List<T>类型的集合,每个T里有两个属性,一个是a元素id,一个是77分数字,多谢,感激不尽
...全文
212 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yongchaochu 2016-09-29
  • 打赏
  • 举报
回复
htmlagilitypack,我之前一直用这个,想着正则更省事
闭包客 2016-09-29
  • 打赏
  • 举报
回复
引用 4 楼 qq_25095899 的回复:
[quote=引用 2 楼 closurer 的回复:] 我写了一个 html 的解析器,用 lambda 查询标签,以后开源出来。
你做的这个东西早有了,而且也是开源 叫CsQuery,让你用C#代码一样的方式解析html,全部都封装好了,只需要调用。[/quote] 谢谢提醒!我对比一下。 有了这个,楼主的问题也就解决了。
大然然 2016-09-29
  • 打赏
  • 举报
回复
引用 2 楼 closurer 的回复:
我写了一个 html 的解析器,用 lambda 查询标签,以后开源出来。
你做的这个东西早有了,而且也是开源 叫CsQuery,让你用C#代码一样的方式解析html,全部都封装好了,只需要调用。
yongchaochu 2016-09-29
  • 打赏
  • 举报
回复
引用 1 楼 qq_20324803 的回复:
用jquery不行?
我是通过webrequest得到的这个xml字符串,想提取关键信息,然后去做其他操作
闭包客 2016-09-28
  • 打赏
  • 举报
回复
我写了一个 html 的解析器,用 lambda 查询标签,以后开源出来。
摇撼大地 2016-09-28
  • 打赏
  • 举报
回复
用jquery不行?

110,571

社区成员

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

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

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