获取id=long这个div中的所有标签的值,如西甲第32轮,皇家马德里,古蒂,伊瓜因等<div class=""info"" id=""long"" style=""display:none;""> <div class=""item""></div> <div class=""item""><span class=""label"">分类:</span><div class=""content"" id=""cateInfoId2""><script>document.getElementById(""cateInfoId2"").innerHTML=document.getElementById(""cateInfo"").innerHTML;</script></div><div class=""clear""></div></div> <div class=""item""><span class=""label"">标签:</span><div class=""content""><a href=""http://www.soku.com/search_video/type_tag_q_%E8%A5%BF%E7%94%B2%E7%AC%AC32%E8%BD%AE"" charset=""400-8-3-0"" target=""_blank"">西甲第32轮</a> <a href=""http://www.soku.com/search_video/type_tag_q_08-09"" charset=""400-8-3-1"" target=""_blank"">08-09</a> <a href=""http://www.soku.com/search_video/type_tag_q_%E7%9A%87%E5%AE%B6%E9%A9%AC%E5%BE%B7%E9%87%8C"" charset=""400-8-3-2"" target=""_blank"">皇家马德里</a> <a href=""http://www.soku.com/search_video/type_tag_q_%E5%8F%A4%E8%92%82"" charset=""400-8-3-3"" target=""_blank"">古蒂</a> <a href=""http://www.soku.com/search_video/type_tag_q_%E4%BC%8A%E7%93%9C%E5%9B%A0"" charset=""400-8-3-4"" target=""_blank"">伊瓜因</a> <a href=""http://www.soku.com/search_video/type_tag_q_%E5%8A%B3%E5%B0%94"" charset=""400-8-3-5"" target=""_blank"">劳尔</a> <a href=""http://www.soku.com/search_video/type_tag_q_%E5%8D%A1%E8%A5%BF%E5%88%A9%E4%BA%9A%E6%96%AF"" charset=""400-8-3-6"" target=""_blank"">卡西利亚斯</a> <a href=""http://www.soku.com/search_video/type_tag_q_%E8%B5%AB%E5%A1%94%E8%8F%B2"" charset=""400-8-3-7"" target=""_blank"">赫塔菲</a> <a href=""http://www.soku.com/search_video/type_tag_q_%E5%B9%BF%E4%B8%9C%E4%BD%93%E8%82%B2"" charset=""400-8-3-8"" target=""_blank"">广东体育</a> </div><div class=""clear""></div></div> <div class=""handle""><div style=""float:left;""><a href=""http://www.youku.com/service/feed/subtype/3/""  charset=""400-03-12"" target=""_blank"">举报</a> <a href=""http://www.youku.com/service/feed/subtype/2/"" charset=""400-03-11"" target=""_blank"">反馈</a></div><a onclick=""Display.changeBlock('short', 'long')"">隐藏</a></div> </div>

解决方案 »

  1.   

     string str = @"<div class='info' id='long' style='display:none;'><div class='item'></div><div class='item'><span class='label'>分类:</span><div class='content' id='cateInfoId2'><script>document.getElementById('cateInfoId2').innerHTML=document.getElementById('cateInfo').innerHTML;</script></div><div class='clear'></div></div><div class='item'><span class='label'>标签:</span><div class='content'><a href='http://www.soku.com/search_video/type_tag_q_%E8%A5%BF%E7%94%B2%E7%AC%AC32%E8%BD%AE' charset='400-8-3-0' target='_blank'>西甲第32轮</a> <a href='http://www.soku.com/search_video/type_tag_q_08-09' charset='400-8-3-1' target='_blank'>08-09</a> <a href='http://www.soku.com/search_video/type_tag_q_%E7%9A%87%E5%AE%B6%E9%A9%AC%E5%BE%B7%E9%87%8C' charset='400-8-3-2' target='_blank'>皇家马德里</a> <a href='http://www.soku.com/search_video/type_tag_q_%E5%8F%A4%E8%92%82' charset='400-8-3-3' target='_blank'>古蒂</a> <a href='http://www.soku.com/search_video/type_tag_q_%E4%BC%8A%E7%93%9C%E5%9B%A0' charset='400-8-3-4' target='_blank'>伊瓜因</a> <a href='http://www.soku.com/search_video/type_tag_q_%E5%8A%B3%E5%B0%94' charset='400-8-3-5' target='_blank'>劳尔</a> <a href='http://www.soku.com/search_video/type_tag_q_%E5%8D%A1%E8%A5%BF%E5%88%A9%E4%BA%9A%E6%96%AF' charset='400-8-3-6' target='_blank'>卡西利亚斯</a> <a href='http://www.soku.com/search_video/type_tag_q_%E8%B5%AB%E5%A1%94%E8%8F%B2' charset='400-8-3-7' target='_blank'>赫塔菲</a> <a href='http://www.soku.com/search_video/type_tag_q_%E5%B9%BF%E4%B8%9C%E4%BD%93%E8%82%B2' charset='400-8-3-8' target='_blank'>广东体育</a> </div><div class='clear'></div></div><div class='handle'><div style='float:left;'><a href='http://www.youku.com/service/feed/subtype/3/'  charset='400-03-12' target='_blank'>举报</a> <a href='http://www.youku.com/service/feed/subtype/2/' charset='400-03-11' target='_blank'>反馈</a></div><a onclick='Display.changeBlock('short', 'long')'>隐藏</a></div></div>";
                string pattern=@">\w+[^:]?<";
                 MatchCollection mc = Regex.Matches(str,pattern);
                 foreach (Match item in mc) 
                 {
                     Console.WriteLine(item.Value.Substring(1,item.Value.Length-2));
                 }
      

  2.   

    将这个代码复制到console application 中并导入 using System.Text.RegularExpression;
    就是你想要的结果