注意:この質問は、以前の質問のより洗練されたバージョンです。
HTML ドキュメント内の特定のプレーン テキストを含む要素を検索できる XPath を探しています。たとえば、次の HTML があるとします。
<html>
<head>...</head>
<body>
<someElement>This can be found</someElement>
<nested>
<someOtherElement>This can <em>not</em> be found most nested</someOtherElement>
</nested>
<yetAnotherElement>This can <em>not</em> be found</yetAnotherElement>
</body>
</html>
テキストで検索する必要があり<someElement>
、次の XPath を使用して検索できます。
//*[contains(text(), 'This can be found')]
プレーンテキストを見つけ<someOtherElement>
て<yetAnotherElement>
使用できる同様の XPath を探しています。以下は機能しません。"This can not be found"
//*[contains(text(), 'This can not be found')]
これはネストされたem
要素が「これは見つかりません」というテキストの流れを「乱す」ためだと理解しています。ある意味で、XPaths を介して、上記のようなネストまたは類似のネストを無視することは可能ですか?