problems with DocumentNode.SelectNodes() parameters

Topics: Developer Forum
Sep 17, 2015 at 9:00 PM
Edited Sep 17, 2015 at 9:11 PM
Hi,
I'm trying to get the following information in the following HTML document (07:34,16:22,08:47) at the bottom of the page . How should I parse the HTML? I have problems finding the right string:
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(sb);
HtmlNodeCollection title =doc.DocumentNode.SelectNodes(???????????????????????????)
thanks
<div class="col-sm-10 col-md-8">
                <table class="table table-striped table-hover well">
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>Sunrise</th>
                            <th>Sunset</th>
                            <th>Day length</th>
                        </tr>
                        <tr>
                            <th colspan="4">
                                <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                                <!-- sunResTimesMonthCenter -->
                                <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-9603966150990290" data-ad-slot="6680811280" data-ad-format="auto"></ins>
                                <script>(adsbygoogle=window.adsbygoogle||[]).push({});</script>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                                                                <tr>
                                                        <td><a href="/en/sun/canada/dorval/2015/january/1" title="Sunrise and sunset times Dorval, January 1, 2015">1 January 2015<span class="hidden-xs hidden-sm underlined">, Thursday</span></a></td>
                            <td>07:34</td>
                            <td>16:22</td>
                            <td>08:47</td>
                        </tr>
Oct 26, 2015 at 6:02 PM
Edited Oct 26, 2015 at 6:03 PM
I am not sure what you are trying to parse out of that HTML. But, for example, if you need href of all anchor tags, you could do:
foreach (var link in doc.DocumentNode.SelectNodes("//a[@href]"))
{
    foreach (var linkAtt in link.Attributes)
    {
        linkAtt.Value.Dump();
    }
}
And you can change parameter for SelectNodes method to be be "//td" or "//div"

Yeah, unfortunately, I don't find complete documentation as well. Would be nice if anyone could point out where to look for.