XPath, how to delete Euro sign unnecessary characters?

395 views Asked by At

How do i select the text in the span tag that excludes those unnecessary "&nbsp" characters? I need only the number (euro character at the end would be nice, but it's not a must). Note that the numbers change, they are not the same.

<span class="price">15.900&nbsp;€</span>
1

There are 1 answers

3
Martin Honnen On BEST ANSWER

If you use C# and XPath then assuming you write your XPath expression as a C# string you can use "translate(//span[@class = 'price'], '\u00A0', '')".

Working sample (in Javascript) is

console.log(document.evaluate("translate(//span[@class = 'price'], '\u00A0', '')", document, null, XPathResult.ANY_TYPE, null).stringValue);
<span class="price">15.900&nbsp;€</span>