title: Select node based on sibling properties - HtmlAgilityPack - C#
body: <p>I have an HTML-document that is structured as follows</p>
  
  <pre><code>&lt;ul class="beverageFacts"&gt;
  &lt;li&gt;
      &lt;span&gt;Vintage&lt;/span&gt; 
      &lt;strong&gt;2007&amp;nbsp;&lt;/strong&gt;
  &lt;/li&gt;
  &lt;li&gt;
      &lt;span&gt;ABV&lt;/span&gt; 
      &lt;strong&gt;13,0&amp;nbsp;%&lt;/strong&gt;
  &lt;/li&gt;
  &lt;li&gt;
      &lt;span&gt;Sugar&lt;/span&gt; 
      &lt;strong&gt;5&amp;nbsp;gram/liter&lt;/strong&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p></p>
  
  <p>I need to parse the values of the <code>&lt;strong&gt;</code>-tags to corresponding <code>string</code>'s, depending on what value the <code>&lt;span&gt;</code>-tag has. </p>
  
  <p>I have the following:</p>
  
  <pre><code>String vintage;
  String sugar;
  String abv;
  </code></pre>
  
  <p>As of now, I am looping through each child node of the <code>beverageFacts</code>-node checking the values to parse it to the correct corresponding <code>string</code>.
  The code I have so far to get the "Vintage"-value is the following, though the result is always <code>null</code>.</p>
  
  <pre><code>HtmlNodeCollection childNodes = bevFactNode.ChildNodes;
  foreach (HtmlNode subNode in childNodes)
  {
      if (subNode.InnerText.TrimStart() == "Vintage")
          vintage = subNode.NextSibling.InnerText.Trim();
  }
  </code></pre>
  
  <p>I believe my selection of the nodes is incorrect, but I cannot figure out how to properly do it in the most efficient way.</p>
  
  <p>Is there an easy way to achieve this?</p>
  
  <hr>
  
  <p><strong>Edit 2013-07-29</strong></p>
  
  <p>I have tried to remove the whitespaces as suggested by <a href="https://stackoverflow.com/users/1037814/enricoariel">enricoariel</a> in the comments using the following code</p>
  
  <pre><code>        HtmlAgilityPack.HtmlDocument page = new HtmlWeb().Load("http://www.systembolaget.se/" + articleID);
  
          string cleanDoc = Regex.Replace(page.DocumentNode.OuterHtml, @"\s*(?&lt;capture&gt;&lt;(?&lt;markUp&gt;\w+)&gt;.*&lt;\/\k&lt;markUp&gt;&gt;)\s*", "${capture}", RegexOptions.Singleline);
  
          HtmlDocument cleanPage = new HtmlDocument();
          cleanPage.LoadHtml(cleanDoc);
  </code></pre>
  
  <p>The resulting is still</p>
  
  <pre><code> String vintage = null;
  </code></pre>