HtmlAgilityPack How to obtain select> and option> in HtmlNode tag

c# html-agility-pack


I want to acquire the HtmlAgilityPack HtmlNode, and I'm using

<select> and <option> and all other html tags.

HtmlNode currently just parses html, table, div, etc. tags. How can I access options and pick tags as well?

My present code is:

if (htmlContent != null)

    if (doc.DocumentNode.SelectNodes("//*") == null)
        List<TagValuePair> tempList = new List<TagValuePair>();
        tempList.Add(new TagValuePair("Error!", htmlContent, -1));
        return tempList;

    foreach (HtmlNode tag in doc.DocumentNode.SelectNodes("//*"))
            if (!string.IsNullOrEmpty(tag.InnerHtml))
                if (!tagAppearance.Keys.Contains(tag.Name))
                    tagAppearance.Add(tag.Name, 1);
                    tagAppearance[tag.Name] = tagAppearance[tag.Name] + 1;

                    new TagValuePair(tag.Name, tag.InnerHtml.Trim(),
            return null;

I attempt to


and I just get certain choice tags. How can I choose the entire + option?


need to download all info from this html's options:

<select onchange="javascript:submitGlobalDiscountSvetisce(this.value);submitGlobalDiscount(this.value);" name="datumper">
                  <option value="18.6.2011|7">18.jun. 7 noči od 515,00&nbsp;EUR</option>
<option value="25.6.2011|7">25.jun. 7 noči od 515,00&nbsp;EUR</option>
<option value="2.7.2011|7">2.jul. 7 noči od 515,00&nbsp;EUR</option>
<option value="9.7.2011|7">9.jul. 7 noči od 515,00&nbsp;EUR</option>
<option value="16.7.2011|7">16.jul. 7 noči od 515,00&nbsp;EUR</option>
<option value="23.7.2011|7">23.jul. 7 noči od 515,00&nbsp;EUR</option>
<option value="30.7.2011|7">30.jul. 7 noči od 529,00&nbsp;EUR</option>
<option value="6.8.2011|7">6.avg. 7 noči od 529,00&nbsp;EUR</option>
<option value="13.8.2011|7">13.avg. 7 noči od 529,00&nbsp;EUR</option>
<option value="20.8.2011|7">20.avg. 7 noči od 529,00&nbsp;EUR</option>
<option value="3.9.2011|7">3.sep. 7 noči od 487,00&nbsp;EUR</option>
<option value="10.9.2011|7">10.sep. 7 noči od 487,00&nbsp;EUR</option>
<option value="17.9.2011|7">17.sep. 7 noči od 487,00&nbsp;EUR</option>
<option value="24.9.2011|7">24.sep. 7 noči od 487,00&nbsp;EUR</option>
<option value="1.10.2011|7">1.okt. 7 noči od 529,00&nbsp;EUR</option>
<option value="8.10.2011|7">8.okt. 7 noči od 529,00&nbsp;EUR</option>
<option value="15.10.2011|7">15.okt. 7 noči od 529,00&nbsp;EUR</option>
<option value="22.10.2011|7">22.okt. 7 noči od 567,00&nbsp;EUR</option>
<option value="29.10.2011|7">29.okt. 7 noči od 567,00&nbsp;EUR</option>

5/6/2011 1:55:36 PM

Popular Answer

OPTION tags are often handled explicitly by default (for historic reasons). See my response on this SO thread at HTML Reading Option for Parsing Use the HtmlAgillityPack to tag content..

5/23/2017 11:47:42 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow