Ответ 1
//span[starts-with(.,'Test')]
Ссылки:
http://www.w3.org/TR/xpath/#function-starts-with
https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/starts-with
Учитывая следующую структуру XML
<html>
<body>
<div>
<span>Test: Text2</span>
</div>
<div>
<span>Test: Text3</span>
</div>
<div>
<span>Test: Text5</span>
</div>
</body>
</html>
Каков наилучший запрос XPath для поиска любого span
с текстом, начинающимся с Test
?
//span[starts-with(.,'Test')]
Ссылки:
http://www.w3.org/TR/xpath/#function-starts-with
https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/starts-with
Действительная опция также:
//span[contains(.,'Test')]