Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trim function in XPath 1.0?

Tags:

xpath

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

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

?

like image 663
Dawid Ohia Avatar asked Jan 18 '10 11:01

Dawid Ohia


People also ask

How do I trim a space in XPath?

As I say, XPath is not a string-handling mechanism; it cannot remove spaces. It is concerned solely with the retrieval of data. Anything you want to do TO that data must be done separately, and currently we don't know what language you're using to do that in.

Which XPath function would you use to trim a text?

XPath/XQuery normalize-space function Returns the value of $arg with leading and trailing whitespace removed, and sequences of internal whitespace reduced to a single space character.

Which of the following XPath function is used to trim trailing spaces?

The normalize-space(String s) method is used to normalize a string i.e. to remove any leading or trailing spaces from the string s passed as parameter to the XPath function.


1 Answers

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

like image 189
Lucero Avatar answered Sep 22 '22 17:09

Lucero