C# Innertext忽略&;前面的所有单词;nbsp;

C# Innertext忽略&;前面的所有单词;nbsp;,c#,html-agility-pack,innertext,C#,Html Agility Pack,Innertext,我正在抓取一个表的内部文本,但是这个列有工具提示,HTMLAgilityPack函数会将工具提示和精确数据一起抓取 假设我只需要他们的名字,而不需要前面的所有单词,包括本身。我可以知道我怎样才能做到这一点吗 Antony Jenkins held the position of CEO at Barclays at the time of this trade. Antony Jenkins Frits Van Paasschen held the position of No

我正在抓取一个表的内部文本,但是这个列有工具提示,HTMLAgilityPack函数会将工具提示和精确数据一起抓取

假设我只需要他们的名字,而不需要前面的所有单词,包括
本身。我可以知道我怎样才能做到这一点吗

Antony Jenkins held the position of CEO at Barclays at the time of this trade. Antony Jenkins
Frits Van Paasschen held the position of Non-Executive Director at Barclays at the time of this trade. Frits Van Paasschen
David A Walker held the position of Non-Executive Chairman at Barclays at the time of this trade. David A Walker
我尝试使用
cols6[j].InnerText.Replace(“,”)
但它显然不会删除前面的单词,除了
本身

任何帮助都将不胜感激!谢谢大家!

根据Alexei的要求,HTML表格如下:

<tr><th>Trade Date</th><th>Action</th><th>Notifier</th><th>Price</th><th>Currency</th><th>Amount</th><th>Holding</th></tr>
<tr class="on"><td>13-Dec-13</td><td>Scrip Dividend</td><td><div class="TradesInfo"><img onmouseover="$('#TradePopD0').css('visibility', 'visible');" onmouseout="$('#TradePopD0').css('visibility', 'hidden');" src="http://static.lse.co.uk/images/icons/info.png" width="14" height="14" align="left" alt="Trade Notifier Information for Barclays"><div class="TradesPop" id="TradePopD0">Antony Jenkins held the position of CEO at Barclays at the time of this trade.</div></div>&nbsp;Antony Jenkins</td><td>0</td><td></td><td>71</td><td>0</td></tr>
Trade DateActionNotifierPriceCurrencyAmountHolding
2013年12月13日股票分割人Tony Jenkins在本次交易时担任巴克莱首席执行官。安东尼·詹金斯0710

一切正常,只有带有工具提示的列。

考虑结合使用String.Substring和String.IndexOf

作为一个非常粗糙的例子

private static string RemoveStringStart(string text)
{
    var splitAt = "&nbsp;";
    if (text.Contains(splitAt))
    {
        text = text.Substring(text.IndexOf(splitAt) + splitAt.Length);
    }

    return text;
}

考虑使用String.Substring和String.IndexOf的组合

作为一个非常粗糙的例子

private static string RemoveStringStart(string text)
{
    var splitAt = "&nbsp;";
    if (text.Contains(splitAt))
    {
        text = text.Substring(text.IndexOf(splitAt) + splitAt.Length);
    }

    return text;
}

考虑使用String.Substring和String.IndexOf的组合

作为一个非常粗糙的例子

private static string RemoveStringStart(string text)
{
    var splitAt = "&nbsp;";
    if (text.Contains(splitAt))
    {
        text = text.Substring(text.IndexOf(splitAt) + splitAt.Length);
    }

    return text;
}

考虑使用String.Substring和String.IndexOf的组合

作为一个非常粗糙的例子

private static string RemoveStringStart(string text)
{
    var splitAt = "&nbsp;";
    if (text.Contains(splitAt))
    {
        text = text.Substring(text.IndexOf(splitAt) + splitAt.Length);
    }

    return text;
}

您可以使用正则表达式忽略所有内容,直到


看看这里:

您可以使用正则表达式忽略所有内容,直到


看看这里:

您可以使用正则表达式忽略所有内容,直到


看看这里:

您可以使用正则表达式忽略所有内容,直到

看看这里:

在Jquery中:

在C#中:

在Jquery中:

在C#中:

在Jquery中:

在C#中:

在Jquery中:

在C#中:


回答我自己的问题,谢谢大家给我的提示:D

我试过这个,效果很好。这不会考虑
中的任何
,而是只考虑
中的“文本”


:)

回答我自己的问题,谢谢大家给我的提示:D

我试过这个,效果很好。这不会考虑
中的任何
,而是只考虑
中的“文本”


:)

回答我自己的问题,谢谢大家给我的提示:D

我试过这个,效果很好。这不会考虑
中的任何
,而是只考虑
中的“文本”


:)

回答我自己的问题,谢谢大家给我的提示:D

我试过这个,效果很好。这不会考虑
中的任何
,而是只考虑
中的“文本”



:)

你能显示HTML吗?获取特定元素的文本可能比尝试解析组合的内部文本要容易得多……嗨,阿列克谢,我已经更新了我的问题,将HTML片段包括在内。:)感谢您的关注。很明显,如果您从特定的
div
元素中获取innerText,您就不需要进行可笑的字符串拆分。关于
div/div[2]
…嗨,阿列克谢,这行
HtmlNodeCollection cols3=rows[i]有没有办法忽略
div
?名称在
中,而不是在
中,因此基本上我想要的是完全忽略两个
中的数据。嗨,Alexei,我尝试了这个方法,效果很好
HtmlNodeCollection cols3=行[i]。选择节点(“.//td[3]/text()”:)你能显示HTML吗?获取特定元素的文本可能比尝试解析组合的内部文本要容易得多……嗨,阿列克谢,我已经更新了我的问题,将HTML片段包括在内。:)感谢您的关注。很明显,如果您从特定的
div
元素中获取innerText,您就不需要进行可笑的字符串拆分。关于
div/div[2]
…嗨,阿列克谢,这行
HtmlNodeCollection cols3=rows[i]有没有办法忽略
div
?名称在
中,而不是在
中,因此基本上我想要的是完全忽略两个
中的数据。嗨,Alexei,我尝试了这个方法,效果很好
HtmlNodeCollection cols3=行[i]。选择节点(“.//td[3]/text()”:)你能显示HTML吗?获取特定元素的文本可能比尝试解析组合的内部文本要容易得多……嗨,阿列克谢,我已经更新了我的问题,将HTML片段包括在内。:)感谢您的关注。很明显,如果您从特定的
div
元素中获取innerText,您就不需要进行可笑的字符串拆分。关于
div/div[2]
…嗨,阿列克谢,这行
HtmlNodeCollection cols3=rows[i]有没有办法忽略
div
?名称在
中,而不是在
中,因此基本上我想要的是完全忽略两个
中的数据。嗨,Alexei,我尝试了这个方法,效果很好
HtmlNodeCollection cols3=行[i]。选择节点(“.//td[3]/text()”:)你能显示HTML吗?获取特定元素的文本可能比尝试解析组合的内部文本要容易得多……嗨,阿列克谢,我已经更新了我的问题,将HTML片段包括在内。:)感谢您的关注。很明显,如果您从特定的
div
元素中获取innerText,您就不需要进行可笑的字符串拆分。关于
div/div[2]
…嗨,阿列克谢,这行
HtmlNodeCollection cols3=rows[i]有没有办法忽略
div
?名称在
中,而不是在
中,因此基本上我想要的是完全忽略两个
中的数据。嗨,Alexei,我尝试了这个方法,效果很好
HtmlNodeCollection cols3=行[i]。选择节点(“.//td[3]/text()”:)