如何使用XPath选择器获取完全匹配的文本?

huangapple go评论60阅读模式
英文:

How to get perfect match text using XPath selector?

问题

所以,仅匹配完全匹配文本的XPath是什么?

XPath for the only perfect matched text is:

仅匹配完全匹配文本的XPath是:

//select[@id="dropdownid"]/option[text()="udhav"]
英文:

For example:

XML file:

<root>
	<dropdwon>
		<option>
			<udhav sarvaiya>
			<udhav sarvaiya v>
			<udhav>
		</option>
	</dropdown>
</root>

I just want to get this string/text in my dropdown: udhav

so, I have used this XPath:

//select[@id="dropdownid"]/option[contains(text(), "udhav")]

but It's giving me 3 outputs:

udhav sarvaiya
udhav sarvaiya v
udhav

I only need output udhav

So, what is XPath for the only perfect matched text?

答案1

得分: 1

尝试使用以下XPath:

//select[@id="dropdownid"]/option[text()="udhav"]

英文:

Try with the below Xpath:

//select[@id="dropdownid"]/option[text()="udhav"]

huangapple
  • 本文由 发表于 2020年1月6日 14:53:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/59607870.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定