This project has moved and is read-only. For the latest updates, please go here.

problems with DocumentNode.SelectNodes() parameters

Topics: Developer Forum
Sep 17, 2015 at 9:00 PM
Edited Sep 17, 2015 at 9:11 PM
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();
HtmlNodeCollection title =doc.DocumentNode.SelectNodes(???????????????????????????)
<div class="col-sm-10 col-md-8">
                <table class="table table-striped table-hover well">
                            <th>Day length</th>
                            <th colspan="4">
                                <script async src="//"></script>
                                <!-- sunResTimesMonthCenter -->
                                <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-9603966150990290" data-ad-slot="6680811280" data-ad-format="auto"></ins>
                                                        <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>
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)
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.