Noor
Noor

Reputation: 20150

get Correct value using xpath

I'm trying to use xpath to get the raw value of an element. The element is a description and it can contain raw text or xhtml.

So it can be as follows:

   <description>asdasdasd <a>Item1</a> asd <a> Price </a></description>

based on the above xml, i just need this:

asdasdasd Item1 asd Price

I've tried //description/text(), //description/descendant::*/text() and some others with no success. Any suggestion?

Upvotes: 0

Views: 168

Answers (1)

BeniBela
BeniBela

Reputation: 16917

Just use:

//description

The value of an element is its text

Or if it must be a string and there is just one element:

string(//description)

Upvotes: 1

Related Questions