在HtmlAgilityPack中获得特定选项? [英] Get a specific option in HtmlAgilityPack?

查看:143
本文介绍了在HtmlAgilityPack中获得特定选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用HtmlAgilityPack获得特定选项?例如,我有一个这样的选择:

is possible get with HtmlAgilityPack a specific option? For example I've a select like this:

<select id="foo">
   <option value="0">1</option>
   <option value="1" selected="selected">2</option> 
</selected>

我需要选择该选项.我知道如何使用以下选项:

I need to get the option with selected. I know how to get the option with:

doc.DocumentNode.SelectNodes("//select[@id='foo']//option");

推荐答案

这应该有效:

doc.DocumentNode.SelectNodes("//select[@id='foo']/option[@selected='selected']");

您可以在此处

这篇关于在HtmlAgilityPack中获得特定选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆