Note that there are some explanatory texts on larger screens.

plurals
  1. POReading out a table in C# with HtmlAgilityPack
    primarykey
    data
    text
    <p>I have been trying for quite a while but this is my case;</p> <p>My friend's web application runs a website with quite simple HTML to generate data for charts. I want to get certain values from a table on that page as he requires this information to be stored to a database.</p> <p>So this is a part of the HTML table;</p> <pre><code>... &lt;tr&gt; &lt;td width=30 align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;1&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;7387&lt;/td&gt; &lt;td width=30 height=25 align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;2&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;2881&lt;/td&gt; &lt;td width=30 height=25 align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;3&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;8782&lt;/td&gt; &lt;td width=30 height=25 align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;4&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;5297&lt;/td&gt; &lt;td width=30 height=25 align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;5&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;749&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;6&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;3136&lt;/td&gt; &lt;td height=25 align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;7&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;8768&lt;/td&gt; &lt;td height=25 align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;8&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;9548&lt;/td&gt; &lt;td height=25 align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;9&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;6565&lt;/td&gt; &lt;td height=25 align=center bgcolor=#006699 class=W&gt;&lt;font color=white&gt;10&lt;/font&gt;&lt;/td&gt; &lt;td width=50 bgcolor=#FFFFFF align=center&gt;142&lt;/td&gt; &lt;/tr&gt; ... </code></pre> <p>What I want to achieve is;</p> <ul> <li>I get two numbers - for example 1 and 8.</li> <li>My application checks the HTML of the page and selects the two <code>td</code> (as shown above) containing the numbers.</li> <li>Then, I have to get the value of the NEXT <code>td</code>.</li> </ul> <p>The output of this would be <code>1=7387</code> and <code>8=9548</code>. I got stuck quite fast after trying to find the two <code>td</code> containing the given numbers.</p> <p>My C# code so far;</p> <pre><code>using (WebClient webClient = new WebClient()) { string completeHTMLCode = webClient.DownloadString("someUrl.php?getChartData=" + chartId); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(completeHTMLCode); foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//td[@...]")) { } } </code></pre> <p>Am I trying something impossible here?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload