<li>
    <h4>
<a target="_blank" href="http://ABC.com">凯美瑞DVD</a>
    </h4>
    <div class="item">
        <div class="pic">
<a title="凯美瑞"  href="http://" target="_blank">
                 <img src="http://imgg"/>
                </a>
        </div>
        <div class="desc">
         <a target="_blank" href="http://870687" class="permalink">凯美瑞</a>
        </div>
        <div class="price">
             <span> 一口价</span>
     <strong>85.00 元</strong>        </div>        
    </div>
</li>
<li>
    <h4>
<a target="_blank" href="http://ABC.com">凯美瑞DVD</a>
    </h4>
    <div class="item">
        <div class="pic">
<a title="凯美瑞"  href="http://" target="_blank">
                 <img src="http://imgg"/>
                </a>
        </div>
        <div class="desc">
         <a target="_blank" href="http://870687" class="permalink">凯美瑞</a>
        </div>
        <div class="price">
             <span> 一口价</span>
     <strong>85.00 元</strong>        </div>        
    </div>
</li>我想从中匹配到h4下的http://ABC.com,和“凯美瑞DVD”这个值...

解决方案 »

  1.   

    直接jQuery遍历得啦。
    例如:$(document).ready(function() {
         $("h4").each(function() {
            alert($(this).html());
         });
     });
      

  2.   

    不行....我是后台处理的,通过HttpWebrequest获取的页面信息
      

  3.   

     string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
                    Regex _reg = new Regex(@"(?<=<h4>[\s\S]*?)<a[^>]*?href=(['""])([^'""]+)\1[^>]*?>([^<]*?)</a>(?=[^<]*?</h4>)");
                    Match m = _reg.Match(tempStr);
                    string href = m.Groups[2].Value;//http://ABC.com
                    string text = m.Groups[3].Value;//凯美瑞DVD
      

  4.   

     
    那再加上个匹配到图片地址<img src="http://imgg"/>的吧
      

  5.   

    再加上个匹配图片地址的....<img src="http://imgg"/>
      

  6.   

    string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
                    Regex _reg = new Regex(@"(?<=<h4>[\s\S]*?)<a[^>]*?href=(['""])([^'""]+)\1[^>]*?>([^<]*?)</a>(?=[^<]*?</h4>)[\s\S]*?<div[^>]*?class=(['""])pic\4[^>]*?>[\s\S]*?(<img[^>]*?>)");
                    Match m = _reg.Match(tempStr);
                    string href = m.Groups[2].Value;//http://ABC.com
                    string text = m.Groups[3].Value;//凯美瑞DVD
                    string img = m.Groups[5].Value;//<img src=\"http://imgg\"/>
      

  7.   

    (?is)<h4>\s*<a\b[^>]*?href="([^"]*?)"[^>]*?>(.*?)</a>\s*</h4>\s*<div\b[^>]*?>\s*<div\b[^>]*?>\s*<a\b[^>]*?>\s*<img\b[^>]*?src="([^"]*?)"[^>]*?/>\s*</a>string HtmlStr = @"html源码";
                    Regex _reg = new Regex(@"(?is)<h4>\s*<a\b[^>]*?href=""([^""]*?)""[^>]*?>(.*?)</a>\s*</h4>\s*<div\b[^>]*?>\s*<div\b[^>]*?>\s*<a\b[^>]*?>\s*<img\b[^>]*?src=""([^""]*?)""[^>]*?/>\s*</a>");
                    Match m = _reg.Match(HtmlStr);
                    string href = m.Groups[1].Value;//http://ABC.com
                    string href = m.Groups[2].Value;//凯美瑞DVD
                    string img=   m.Groups[3].Value;//http://imgg
      

  8.   

     
    还是再改下吧,换成获取具体的图片地址http://imgg\
      

  9.   

    自己都不清楚想要什么吗?string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt", Encoding.GetEncoding("GB2312"));//读取txt
                    Regex _reg = new Regex(@"(?<=<h4>[\s\S]*?)<a[^>]*?href=(['""])([^'""]+)\1[^>]*?>([^<]*?)</a>(?=[^<]*?</h4>)[\s\S]*?<div[^>]*?class=(['""])pic\4[^>]*?>[\s\S]*?<img[^>]*?src=(['""])([^'""]+)\5[^>]*>");
                    Match m = _reg.Match(tempStr);
                    string href = m.Groups[2].Value;//http://ABC.com
                    string text = m.Groups[3].Value;//凯美瑞DVD
                    string img = m.Groups[6].Value;//http://imgg