Reputation: 31
I need to get the text (Bulk Template
) after the text()='Template: '
.
<div class="description secondary-text">
<strong data-issue-type-field="name">Template: </strong>
<span class="description secondary-text">Bulk Template</span>
<strong data-issue-type-field="name">Save Locally: </strong>
<span class="description secondary-text">c:\</span>
</div>
I've tried with this XPath expression:
//strong[@data-issue-type-field][text()='Template: ']/../span
but it retrieved two results.
Upvotes: 0
Views: 931
Reputation: 168157
The "next" element at the "same level" in XPath world is called following-sibling therefore the XPath expression you're looking for is:
//strong[contains(text(),'Template')]/following-sibling::span
More information:
Upvotes: 1
Reputation:
Select the first matching element:
//strong[@data-issue-type-field][text()='Template: ']/../span[1]
Upvotes: 1