Jakes
Jakes

Reputation: 409

XPath to element text

<p><span class="label">key</span>value</p>

How am I able to get just the "value" out using xPath? I managed to get to the element using the following expression:

//span[@class='label']/..

Upvotes: 1

Views: 40

Answers (2)

supputuri
supputuri

Reputation: 14145

You just have to use text() to get the text from the p

//span[@class='label']/../text()

enter image description here

Upvotes: 0

JaSON
JaSON

Reputation: 4869

Try this one to get required value:

//p[span[@class='label']]/text()

Upvotes: 2

Related Questions