给出以下XML结构
<html>
<body>
<div>
<span>Test: Text2</span>
</div>
<div>
<span>Test: Text3</span>
</div>
<div>
<span>Test: Text5</span>
</div>
</body>
</html>
找到包含以span
开头的文字的任何Test
的最佳XPath查询是什么?
答案 0 :(得分:23)
//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
答案 1 :(得分:4)
有效选项也是:
//span[contains(.,'Test')]