質問
次の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/ #function-starts-with
https://developer.mozilla.org / en-US / docs / Web / XPath / Functions / starts-with
他のヒント
有効なオプションも:
//span[contains(.,'Test')]
所属していません StackOverflow