需要以下HTML代码的通用xpath [英] Need generic xpath for the following html code

查看:73
本文介绍了需要以下HTML代码的通用xpath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我需要唯一的XPath的HTML代码.

Following is the HTML code for which I need a unique XPath.

<fieldset>
<legend>Type</legend>
<input id="applyremotewhite" name="rvaluetype" checked="checked"     value="white" type="radio">
<label for="applyremotewhite">White List</label>
<br>
<br>
<input id="applyremoteblack" name="rvaluetype" value="black" type="radio">
<label for="applyremoteblack">Black List</label>
</fieldset>
<fieldset>

我需要类似[@label ='White List']的东西,因此我无需在代码中编写多个xpath.我想从函数中传递白名单和黑名单之类的值.

I need something like [@label = 'White List'] so that I need not write multiple xpaths in my code. I want to pass values like White List and Black List from a function.

推荐答案

如果返回了多个匹配的节点,则可以使用以下索引来获取预期的节点.

You can use index as below to get the expected node if multiple matching nodes are returned.

(label[text() = 'White List'])[N]

"N"将是您要处理的节点的索引.

'N' would be the index of node you want to work upon.

这篇关于需要以下HTML代码的通用xpath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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