通配符与 xpath 的使用 [英] wildcard usage with xpath

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

问题描述

我在使用 xpath 选择以下两个标签时遇到问题:

<div class="table-row">

我尝试过:

"//div[@class='table-row*']"

但这与以上任何一项都不匹配.

我做错了什么?感谢您的帮助.

解决方案

使用 starts-with 来匹配通配符 '*'

//div[starts-with(@class, 'table-row')]

I'm having problems with selecting both following tags with xpath:

<div class="table-row">
<div class="table-row ">

I tried with:

"//div[@class='table-row*']"

but this won't match any of above.

What am I doing wrong? Thanks for help.

解决方案

Use starts-with to match in the place of wildcard '*'

//div[starts-with(@class, 'table-row')]

这篇关于通配符与 xpath 的使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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