[英]XML - XPath to return element that brother element contains certain text
[英]XPath for an element that contains another element with certain text?
你可以試試
//button[contains(div,'Save')]
使用包含特定文本的子div
定位button
小心,另一個答案//button[contains(div,'Save')]
在這種情況下有效,但請注意它會在以下情況下失敗
button
包含一個span
或另一個或沒有元素,而不是一個div
。div
元素一起存在,其字符串值包含子字符串"Save"
: "Save this"
、 "Save that"
、 "Jesus Saves"
等。這個 XPath,
//button[normalize-space() = 'Save']
將選擇空間標准化字符串值恰好為"Save"
button
元素。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.