xml - 带有法语特殊字符 (è d') 的无效 XPath
问题描述
如果 XPath 包含法语特殊字符(è d'),似乎 XPath 不起作用,出现以下错误
InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression
//*[@class='v-menubar-menuitem']/*[contains(text(), 'Afficher la bibliothèque d'autorisations')]
because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document':
The string '//*[@class='v-menubar-menuitem']/*[contains(text(), 'Afficher la bibliothèque d'autorisations')]' is not a valid XPath expression.
运行 windows 机器,也为 File 更改了 EOL(UTF-8,基于 unix),但不工作。
当我们以英语本地化运行时,这很好用
解决方案
è
在 XPath 中使用字符并没有错。
另一方面,d'
不是单个字符,而是 ad
后跟单引号'
,并且单引号干扰了在 XPath 中用作字符串分隔符的单引号。
如果您将字符串分隔符更改为使用双引号,则内部单引号不会有问题:
//*[@class='v-menubar-menuitem']
/*[contains(text(), "Afficher la bibliothèque d'autorisations")]
推荐阅读
- c++ - 如何在 Qt 中复制和粘贴自定义对象
- javascript - Fullcalendar.io 如何从标题中截取“上一个”和“下一个”
- ios - 在已弃用的 NSURLConnectionDelegate 上报告了 MITM 攻击
- javascript - 在 AWS Lambda 中使用 NodeJS 将 Woocommerce API 函数更改为异步/等待
- c++ - 在Qt中进行多次图形更改时如何最小化屏幕闪烁?
- types - 函数类型:不能用 abi.decode 解码
- java - 使用 OAuth 1.0 请求 Twitter api
- opendaylight - Opendaylight neon:旧 l2switch 功能的替代品
- python - 如何使python循环“不等待”完成上一个命令?
- sql - SQL:对两个连接表的值求和