Reputation: 461
I can select a element that containing a specific word,
//p[@class="class"][contains(text(),"disease")]
But I wanna select the word alone using xpath.,
Upvotes: 2
Views: 1457
Reputation: 111686
If you stretch what you mean by selection to include values returned by XPath functions against actually selected nodes, you can use string functions to extract a word from the string value of a node.
For example, for this XML,
<a>Label: WORD</a>
this XPath,
substring-after(/a,"Label: ")
will return
WORD
as requested.
Upvotes: 3
Reputation: 6674
XPath is for traversing the XML-based documents. XML would consider the text content as one entity and XPath won't distinguish among the words it contains.
Upvotes: 0