Get href tags in html data in c#
<p>I am using web client class to HTML data from a web page. Now I want to get the complete href tags and there titles from the HTML data. Initially I used loops, Felling inefficient I switched to regExp, but dint got efficient solution.</p>

<p>He is the initial code:</p>

<pre><code>for (int i = 0; i &lt; htmldata.Length - 5; i++)
{
  if (htmldata.Substring(i, 5) == "href=")
  {
    n1 = htmldata.Substring(i + 6, htmldata.Length - (i + 6)).IndexOf("\"");
    Sublink = htmldata.Substring(i + 6, n1);
    var absoluteUri = new Uri(baseUri, temp);
    n2 = htmldata.Substring(i + n1 + 1, htmldata.Length - (i + n1 + 1)).IndexOf("&lt;");
    subtitle = htmldata.Substring(i + 6 + n1 + 2, n2 - 7); 
  }
}
</code></pre>

<p>This code is getting some of the links like this.</p>

<pre><code>/l.href.replace(new RegExp(

/advanced_search?hl=en&amp;q=&amp;hl=en&amp;
</code></pre>

<p>and titles like this</p>

<pre><code>onclick=gbar.qs(this) class=gb2&gt;Photos

")+"q="+encodeURIComponent(b)})}i.qs=n;function o(a,b,d,c,f,e){var g=document.getElementById(a);if(g){var 
</code></pre>

<p>Which are absolutely invalid.
Please suggest me the correct code for getting valid relative href links and titles.</p>
