【发布时间】:2019-03-07 15:45:16
【问题描述】:
我想将<button> 元素与某个文本匹配,该文本有时会在按钮内的另一个元素中关闭,例如:
<div @class="buttonset">
<button>Close</button>
</div>
<div @class="buttonset">
<button>
<span>Close</span>
</button>
</div>
xpath 查询//div[@class='modal-buttonset']/button[text()='Cancel'] 只给我最高级别的结果。
如何匹配各级文字?
【问题讨论】:
-
XML 和 HTML 中的属性不以
@开头——您的示例将标记语法与 XPath 语法混淆了。希望这是一个问题错字,而不是您的实际数据。