32

Is there a trim function in XPath 1.0, that can be used like this:

.//a[trim(.) = @href)]

?

Dawid Ohia
  • 16,129
  • 24
  • 81
  • 95

1 Answers1

45

There is normalize-space(), which does a little more than trimming, but which may be fine for URLs.

Lucero
  • 59,176
  • 9
  • 122
  • 152
  • 1
    Will the xpath `//button[normalize-space(text())='Brave Boy']` work for an element `` – Rameshwar Jun 09 '17 at 07:37
  • @Rameshwar Nonbreaking space is not directly supported, however you can translate those to normal spaces first so it will work. See also https://stackoverflow.com/questions/40925537/xslt-normalize-non-breaking-whitespace-characters – Lucero Jun 09 '17 at 07:41