题
给出以下XML结构
<html>
<body>
<div>
<span>Test: Text2</span>
</div>
<div>
<span>Test: Text3</span>
</div>
<div>
<span>Test: Text5</span>
</div>
</body>
</html>
使用以 Test
开头的文本找到任何 span
的最佳XPath查询是什么?
解决方案
//span[starts-with(.,'Test')]
结果,参考文献:
http://www.w3.org/TR/xpath/ #函数开始-与
https://developer.mozilla.org / EN-US /文档/网络/ XPath的/功能/启动,与
其他提示
有效选项也是:
//span[contains(.,'Test')]
不隶属于 StackOverflow