title: Parsing HTML using HTTP Agility Pack
body: <p>Here is one table out of 5:</p>
  
  <pre><code>&lt;h3&gt;marec - maj 2009&lt;/h3&gt;
  &lt;div class="graf_table"&gt;
  &lt;table summary="layout table"&gt;
      &lt;tr&gt;
          &lt;th&gt;DATUM&lt;/th&gt;
          &lt;td class="datum"&gt;10.03.2009&lt;/td&gt;
          &lt;td class="datum"&gt;24.03.2009&lt;/td&gt;
          &lt;td class="datum"&gt;07.04.2009&lt;/td&gt;
          &lt;td class="datum"&gt;21.04.2009&lt;/td&gt;
          &lt;td class="datum"&gt;05.05.2009&lt;/td&gt;
          &lt;td class="datum"&gt;06.05.2009&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;th&gt;Maloprodajna cena [EUR/L]&lt;/th&gt;
          &lt;td&gt;0,96000&lt;/td&gt;
          &lt;td&gt;0,97000&lt;/td&gt;
          &lt;td&gt;0,99600&lt;/td&gt;
          &lt;td&gt;1,00800&lt;/td&gt;
          &lt;td&gt;1,00800&lt;/td&gt;
          &lt;td&gt;1,01000&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;th&gt;Maloprodajna cena [SIT/L]&lt;/th&gt;
          &lt;td&gt;230,054&lt;/td&gt;
          &lt;td&gt;232,451&lt;/td&gt;
          &lt;td&gt;238,681&lt;/td&gt;
          &lt;td&gt;241,557&lt;/td&gt;
          &lt;td&gt;241,557&lt;/td&gt;
          &lt;td&gt;242,036&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;th&gt;Prodajna cena brez dajatev&lt;/th&gt;
          &lt;td&gt;0,33795&lt;/td&gt;
          &lt;td&gt;0,34628&lt;/td&gt;
          &lt;td&gt;0,36795&lt;/td&gt;
          &lt;td&gt;0,37795&lt;/td&gt;
          &lt;td&gt;0,37795&lt;/td&gt;
          &lt;td&gt;0,37962&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;th&gt;Trošarina&lt;/th&gt;
          &lt;td&gt;0,46205&lt;/td&gt;
          &lt;td&gt;0,46205&lt;/td&gt;
          &lt;td&gt;0,46205&lt;/td&gt;
          &lt;td&gt;0,46205&lt;/td&gt;
          &lt;td&gt;0,46205&lt;/td&gt;
          &lt;td&gt;0,46205&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;th&gt;DDV&lt;/th&gt;
          &lt;td&gt;0,16000&lt;/td&gt;
          &lt;td&gt;0,16167&lt;/td&gt;
          &lt;td&gt;0,16600&lt;/td&gt;
          &lt;td&gt;0,16800&lt;/td&gt;
          &lt;td&gt;0,16800&lt;/td&gt;
          &lt;td&gt;0,16833&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have to extract out values, where table header is DATUM and Maloprodajna cena [EUR/L].
  I am using Agility HTML pack.</p>
  
  <pre><code>this.htmlDoc = new HtmlAgilityPack.HtmlDocument();
  this.htmlDoc.OptionCheckSyntax = true;
  this.htmlDoc.OptionFixNestedTags = true;
  this.htmlDoc.OptionAutoCloseOnEnd = true;
  this.htmlDoc.OptionOutputAsXml = true; // is this necessary ??
  this.htmlDoc.OptionDefaultStreamEncoding = System.Text.Encoding.Default;
  </code></pre>
  
  <p>I had a lot of trouble with getting those values out.
  I started with:</p>
  
  <pre><code> var query = from html in doc.DocumentNode.SelectNodes("//div[@class='graf_table']").Cast&lt;HtmlNode&gt;()
   from table in html.SelectNodes("//table").Cast&lt;HtmlNode&gt;()
   from row in table.SelectNodes("tr").Cast&lt;HtmlNode&gt;()
   from cell in row.SelectNodes("th|td").Cast&lt;HtmlNode&gt;()
   select new { Table = table.Id, CellText = cell.InnerHtml };
  </code></pre>
  
  <p>but could not figure out a way to select only values where table header is DATUM and Maloprodajna cena[EUR/L]. Is it possible to do that with where clause?</p>
  
  <p>Then I ended with those two queries:</p>
  
  <pre><code>var date = (from d in htmlDoc.DocumentNode.SelectNodes("//div[@class='graf_table']//table//tr[1]/td")
                      select DateTime.Parse(d.InnerText)).ToArray();
  
  var price = (from p in htmlDoc.DocumentNode.SelectNodes("//div[@class='graf_table']//table//tr[2]/td")
                       select double.Parse(p.InnerText)).ToArray();
  </code></pre>
  
  <p>Is it possible to combine those two queries?
  And how would I convert that to lambda expression?
  I just started to learn those things and I would like to know how it is done so that in the future I would not have those question.</p>
  
  <p>O, one more question ... does anybody know any graph control, cause I have to show those values in graph.
  I started with Microsoft Chart Controls, but I am having trouble with setting it.
  So if anyone has any experience with it I would like to know how to set it, so that x axle will show all values not every second ... example:
  if I have: 10.03.2009, 24.03.2009, 07.04.2009, 21.04.2009, 05.05.2009, 06.05.2009
  it show only: 10.03.2009,  07.04.2009, 05.05.2009, ect.</p>
  
  <p>I bind data to graph like that:</p>
  
  <pre><code>chart1.Series["Series1"].Points.DataBindXY(date, price);
  </code></pre>
  
  <p>I lot of questions for my fist post ... hehe, hope that I was not indistinct or something.
  Thank's for any reply!</p>