获得2 html标签C#之间的文本 [英] Get text between 2 html tags c#

查看:101
本文介绍了获得2 html标签C#之间的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图获得提供的HTML(跨度)之间的数据(在这种情况下,31)

下面是原来的code(从检查中铬元素)


 <跨度ID =point_total级=工具提示oldtitle =注意:如果数字是黑色的,你的观点实际上是一点点的负面不要担心,这只是意味着你需要重新开始底层。 ARIA-describedby的=UI-提示-0> 31 LT; / SPAN>


我有一个格式文本框,其中包含的页面的源代码,这里是同一code,但在富文本框的51行:


 < D​​IV ID = point_display>您有< BR>< SPAN ID = point_total类=提示jQuery16207621750175125325 =23oldtitle =注意:如果号码为黑色,你点实际上有点消极别担心,这只是意味着你需要重新开始底涂> 17< / SPAN>< BR>点< / DIV>< IMG风格=FLOAT:。右标题=增益用户BORDER = 0 ALT =当人们订阅你,你失去了点SRC =http://static.subxcess.com/images/page/decoration/remove-1-point.png > < / DIV>


我将如何去这样做呢?我尝试了好几种方法和他们都不为我工作。

我尝试从这个页面的点值: http://www.subxcess.com/ sub4sub.php
数量的变化取决于谁潜艇你。


解决方案

您可能是令人难以置信的具体看:

  VAR的regex ​​=新的正则表达式(@?<跨度ID =point_total阶级=工具提示,oldtitle =*唱段,describedby的= UI-提示-0>&LT(*);?/ SPAN>);VAR匹配= regex.Match(@<跨度ID =point_total阶级=工具提示,oldtitle =注意:如果号码是黑色的,你的观点实际上是一点点的负面不要。担心,这只是意味着你需要重新开始底层,咏叹调-describedby的=UI-提示-0。> 31 LT; / SPAN>);VAR的结果= match.Groups [1] .value的;

I am trying to get the data between the html (span) provided (in this case 31)

Here is the original code (from inspect elements in chrome)

<span id="point_total" class="tooltip" oldtitle="Note: If the number is black, your points are actually a little bit negative.  Don't worry, this just means you need to start subbing again." aria-describedby="ui-tooltip-0">31</span>

I have a rich textbox which contains the source of the page, here is the same code but in line 51 of the rich textbox:

<DIV id=point_display>You have<BR><SPAN id=point_total class=tooltip jQuery16207621750175125325="23" oldtitle="Note: If the number is black, your points are actually a little bit negative.  Don't worry, this just means you need to start subbing again.">17</SPAN><BR>Points </DIV><IMG style="FLOAT: right" title="Gain subscribers" border=0 alt="When people subscribe to you, you lose a point" src="http://static.subxcess.com/images/page/decoration/remove-1-point.png"> </DIV>

How would I go about doing this? I have tried several methods and none of them seem to work for me.

I am trying to retrieve the point value from this page: http://www.subxcess.com/sub4sub.php The number changes depending on who subs you.

解决方案

You could be incredibly specific about it:

var regex = new Regex(@"<span id=""point_total"" class=""tooltip"" oldtitle="".*?"" aria-describedby=""ui-tooltip-0"">(.*?)</span>");

var match = regex.Match(@"<span id=""point_total"" class=""tooltip"" oldtitle=""Note: If the number is black, your points are actually a little bit negative.  Don't worry, this just means you need to start subbing again."" aria-describedby=""ui-tooltip-0"">31</span>");

var result = match.Groups[1].Value;

这篇关于获得2 html标签C#之间的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆