Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: Help Locating This Table Please

$
0
0

Hi

Please can someone show me where I'm going wrong, I cant get the path correct to get the table data. I'm looking to get table rows and data from sTable. sTable actually appears twice on the page. I do need the data from both but I dont have a problem running 2 queries if its easier.

The page html looks like this

<div class="col6">		
<table class="sTable">
<caption>Information</caption>
<tbody>
<tr>
<th scope="row">Type</th>
<td>Broken</td>
</tr>
</tbody>
<tbody>
<tr>
<th scope="row">Make</th>
<td>Fors</td>
</tr>
</tbody>
</table>

<table class="sTable">
<caption>Functions</caption>
<tbody>
<tr>
<th scope="row">Number of Functions</th>
<td>16</td>
</tr>
</tbody>
<tbody>
<tr>
<th scope="row">Timer</th>
<td>198 minutes</td>
</tr>
</tbody>
</table>
</div>

Here is my code so far, although it does not work

string stockPath = "//div[@class=\'col6\']";                     
HtmlNodeCollection nct = hd.DocumentNode.SelectNodes(stockPath);
HtmlNodeCollection tbs = nct[0].SelectNodes(".//table");
foreach (HtmlNode hn in tbs[0].ChildNodes)
                     {
                            if (hn.Name == "tbody")
                            {
        HtmlNodeCollection rows = hn.SelectNodes(".//tr");
                               
                                for (int i = 0; i < rows.Count; ++i)
                                {
        HtmlNodeCollection cols = rows[i].SelectNodes(".//td");
                                                                   
                                    string value = cols[0].InnerText;
                    for (int l = 0; l < tempArray.Length / 2; l++)
                                    {
                     if (tempArray[l, 0].Replace("_", " ") == value)
                                        {
                               tempArray[l, 1] = cols[1].InnerText;
                                        }
                                    }
                                }

                            }
                        }
                        specstr = GetArraySpec(tempArray);
                    }
                }

not sure if this helps or not but on another discussion, I read about how to get the path using firebug and this is what I ended up with

/html/body/div/div/section/div[5]/section[2]/div/div[2]/table

Really appreciated anyones time and advice on this as its been doing my head in for hours :(

 

 

 


Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>