title: HTML string, get the first href
body: <p>I'm writing a C# script in SSIS-2016, Using Visual Studio-2015.</p>
  
  <p>Requirement: Download the HTML from the URL and get the earliest Date (href) and set this date as a variable.</p>
  
  <p>I've got this so far:</p>
  
  <pre><code>public void Main()
  {
      string username = Dts.Variables["$Package::user"].Value.ToString();
      string password = Dts.Variables["$Package::pwd"].Value.ToString();
      string URL = Dts.Variables["$Package:URL"].Value.ToString();
  
      WebRequest request = WebRequest.Create(URL);
      request.Credentials = new NetworkCredential(username, password);
      var webResponse = request.GetResponse();
      Stream dataStream = webResponse.GetResponseStream();
      StreamReader reader = new StreamReader(dataStream);
      string responseFromServer = reader.ReadToEnd();
  </code></pre>
  
  <p>So the HTML will look like this:</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;&lt;title&gt;Index of /file-download/&lt;/title&gt;&lt;/head&gt;
      &lt;body bgcolor="white"&gt;
      &lt;h1&gt;Index of /file-download/&lt;/h1&gt;&lt;hr&gt;&lt;pre&gt;&lt;a href="../"&gt;../&lt;/a&gt;
      &lt;a href="20170826/"&gt;20170826/&lt;/a&gt;                                          27-Aug-2017 00:05                   -
      &lt;a href="20170827/"&gt;20170827/&lt;/a&gt;                                          28-Aug-2017 00:05                   -
      &lt;a href="20170828/"&gt;20170828/&lt;/a&gt;                                          29-Aug-2017 00:05                   -
      &lt;a href="ProductDefinitions/"&gt;ProductDefinitions/&lt;/a&gt;                                26-Aug-2017 16:58                   -
      &lt;a href="file-download-automation.readme.txt"&gt;file-download-automation.readme.txt&lt;/a&gt;                12-Aug-2017 01:56                1061
      &lt;/pre&gt;&lt;hr&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>What I need to do is somehow get the Earliest Dated <code>href</code> from the string <code>responseFromServer</code>, I can then pass this to a <code>DTS.Variable</code>.</p>
  
  <p>I've seen loads of regex answers but I cannot get it to work for me.</p>
  
  <p>If anyone could help I would be really appreciative.</p>