<div id="table_body"> 
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab02"> 
<tr class="trbg" onmouseover="this.className='caing_hover'" onmouseout="this.className='trbg'"> 
<td width="25%">11年7月</td>
<td width="25%">45,183.07</td>
<td width="25%">270,558.64</td>
<td width="25%">772,937.56</td>
</tr><tr  onmouseover="this.className='caing_hover'" onmouseout="this.className=''"> 
<td width="25%">11年6月</td>
<td width="25%">44,477.80</td>
<td width="25%">274,662.57</td>
<td width="25%">780,820.85</td>
</tr><tr class="trbg" onmouseover="this.className='caing_hover'" onmouseout="this.className='trbg'"> 
<td width="25%">11年5月</td>
<td width="25%">44,602.83</td>
<td width="25%">269,289.63</td>
<td width="25%">763,409.22</td>
</tr><tr  onmouseover="this.className='caing_hover'" onmouseout="this.className=''"> 
<td width="25%">11年4月</td><td width="25%">45,489.03</td>
<td width="25%">266,766.91</td>
<td width="25%">757,384.56</td>
</tr>
</table>
</div>我想获取<td></td>间的值,不知怎么获取,请大家指点一二?

解决方案 »

  1.   

    这是你要的~在你的Form1放一个 RichTextBox 试试吧
                string yourStr = @" <div id='table_body'> 
                                    <table width='100%' border='0' cellspacing='0' cellpadding='0' class='tab02'> 
                                    <tr class='trbg' onmouseover='this.className='caing_hover'' onmouseout='this.className='trbg''> 
                                    <td width='25%'>11年7月</td>
                                    <td width='25%'>45,183.07</td>
                                    <td width='25%'>270,558.64</td>
                                    <td width='25%'>772,937.56</td>
                                    </tr>
                                    <tr onmouseover='this.className='caing_hover'' onmouseout='this.className='''> 
                                    <td width='25%'>11年6月</td>
                                    <td width='25%'>44,477.80</td>
                                    <td width='25%'>274,662.57</td>
                                    <td width='25%'>780,820.85</td>
                                    </tr>
                                    <tr class='trbg' onmouseover='this.className='caing_hover'' onmouseout='this.className='trbg''> 
                                    <td width='25%'>11年5月</td>
                                    <td width='25%'>44,602.83</td>
                                    <td width='25%'>269,289.63</td>
                                    <td width='25%'>763,409.22</td>
                                    </tr>
                                    <tr onmouseover='this.className='caing_hover'' onmouseout='this.className='''> 
                                    <td width='25%'>11年4月</td><td width='25%'>45,489.03</td>
                                    <td width='25%'>266,766.91</td>
                                    <td width='25%'>757,384.56</td>
                                    </tr>
                                    </table>
                                    </div>";            System.Text.RegularExpressions.MatchCollection mc = System.Text.RegularExpressions.Regex.Matches(yourStr, @"(?is)(?<=<td[^>]*>)(?!\s*</td)(?:(?!</td\b).)*(?=</td>)");
                foreach (System.Text.RegularExpressions.Match m in mc)
                {
                    string temp = System.Text.RegularExpressions.Regex.Replace(m.Value, @"<[^>]*>|\s+", "");
                    if (temp != "")
                        richTextBox1.Text += temp + "\n";
                }