Read html file and get the value of a selected select

0

I'm reading an html file and need to get the value of value of the select selected by the user, how to do it?

HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
var select = doc.DocumentNode.SelectNodes("//table//tr//td//select[@class='CC_CxComboBox']");
foreach (var item in select)
{
    var _value = item... //"como pegar o valor do atributo value do select"
}

This is HTML

 <table>    
        <tr>        
            <td Class='Tit08'>CNPJ:&nbsp; 09876543210000  -  JOÃO DA SILVA      </td>
            <td Class='Tit08'>Grupo:&nbsp;                  
                <select id='grupo' class='CC_CxComboBox'>
                    <option value=''>Selecione</option>
                    <option value=02161 selected>SÃO PAULO</option>         
                </select>
            </td>
        </tr>
    </table>
    
asked by anonymous 31.01.2018 / 18:20

1 answer

1
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(str);
var select = doc.DocumentNode.SelectNodes("//table//tr//td//select[@class='CC_CxComboBox']//option[@selected]");
foreach (var item in select)
{
    var _value = item.Attributes["value"].Value;
    var _description = item.InnerHtml;
}
    
31.01.2018 / 19:11