分析字符串没什么难度
就是麻烦点~~~可以考虑正则或者把它弄成XML

解决方案 »

  1.   

    <td height="30" colspan="6"><font color="#FFFFFF">1/K1 平海路→小河路登云路口</font></td>
                        </tr>
                        <tr align="center" valign="top" bgcolor="FFECC3"> 
                          <td width="5%" height="30">序号</td>
                          <td width="17%" height="30">站点名称<br>
                            Bus Stops Name </td>
                          <td width="46%" height="30">经过线路<br>
                            Buslines Passing By </td>
                          <td width="12%" height="30">副站名<br>
                            Subname Of The Busstop </td>
                          <td width="20%" height="30">辅助标注站名<br>
                            Supplementary Name of Bus Stops </td>
                        </tr>
                        
                        <tr align="center" bgcolor="ECF4F9"> 
                          <td height="30">1</td>
      <td height="30">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr> 
                                <td width="44%" align="center"> 
                                  
                                平海路</td>
                              </tr>
                            </table>
                          </td>
                          <td height="30"> 
      <table border=0 width="100%"><tr>
      
    <td width="25%" align="center"><a href="line_search.jsp?line_id=3&line_name=K4" target="_blank">K4</a></td>

    <td width="25%" align="center"><a href="line_search.jsp?line_id=895&line_name=27" target="_blank">27/K27</a></td>

    <td width="25%" align="center"><a href="line_search.jsp?line_id=1307&line_name=K16" target="_blank">K16</a></td>

    <td width="25%" align="center"><a href="line_search.jsp?line_id=1321&line_name=K286" target="_blank">K286</a></td>

      </tr>
      
    <tr><td colspan="25%" align="right"><a href="line_more.jsp?stop_name=平海路" target="_blank">更多线路</a></td></tr>
      
    </table>
                          </td>
    <td height="30"> 
                            市总工会
                          </td>
                          <td height="30"> 
                            
                          </td>
                        </tr>
      
                        <tr align="center" bgcolor="ECF4F9"> 
                          <td height="30">2</td>
      <td height="30">
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                              <tr> 
                                <td width="44%" align="center"> 
                                  
                                十四中</td>
                              </tr>
                            </table>
                          </td>
                          <td height="30"> 
      <table border=0 width="100%"><tr>
      
    <td width="25%" align="center"><a href="line_search.jsp?line_id=1246&line_name=K73" target="_blank">K73</a></td>

    <td width="25%" align="center"><a href="line_search.jsp?line_id=1257&line_name=49" target="_blank">49/K49</a></td>

    <td width="25%" align="center"><a href="line_search.jsp?line_id=1793&line_name=45" target="_blank">45/K45</a></td>

    <td width="25%" align="center"><a href="line_search.jsp?line_id=1913&line_name=1" target="_blank">1/K1</a></td>

      </tr>
      
    <tr><td colspan="25%" align="right"><a href="line_more.jsp?stop_name=十四中" target="_blank">更多线路</a></td></tr>
      
    </table>
      

  2.   

    这些是其中的一小段,下面还很多,我想提取的是stop_name=??后面??的内容,比如平海路,十四中,希望高手可以指点,谢谢..
      

  3.   

    如果不考虑性能问题,也可以简单点
    先用String.IndexOf() 取得第一个"stop_name="的索引,然后把后面的内容截取出来;再把前面已经截取的部分SubString掉,对剩下的内容继续执行String.IndexOf() 直到没有匹配伪代码如下:
    String s = "..........html内容........";
    int i = 0;
    while(s.IndexOf("stop_name=")>=0)
    {
    ......
    }
      

  4.   

    用split,"stop_name=" 为分割关键字
      

  5.   


    string content = "<a   href=\"line_more.jsp?stop_name=十四中\"   target=\"_blank\"> ";
                string regex = "<a[\\s\\S]+?stop_name=(?<keyword>.*?)\"[\\s\\S]+?>";
                System.Text.RegularExpressions.RegexOptions options = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Multiline) 
                            | System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(regex, options);            System.Text.RegularExpressions.MatchCollection resultes = reg.Matches(content);
                foreach (System.Text.RegularExpressions.Match item in resultes)
                {
                    //item.Groups["keyword"].Value就为其stop_name的值
                    //Response.Write(item.Groups["keyword"].Value);
                    //MessageBox.Show(item.Groups["keyword"].Value);
                }