从特定的起始位置获取选项? [英] Get option from specific start position?

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

问题描述

我有一个这样的选择:

<select class="foo">
    <option></option>
    <option>item1</option>
    <option>item2</option>
</select>

我只需要获取其中包含文本的选项,因此我需要跳过第一个选项,仅获取Item1Item2

I need to get only the option that have text inside, so I need to skip the first option and get only Item1 and Item2

我做了

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

这当然会返回3个选项,我该怎么做?谢谢.

this will return of course 3 options, how can I do this? Thanks.

推荐答案

工作的xpath:

"//select[@class='foo']//option[string-length( text()) > 0]"

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

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