Retrieve an xpath text contains using text()

text() gets you a set of text nodes. I tend to use it more in a context of //span//text() or something.

If you are trying to check if the text inside an element contains something you should use contains on the element rather than the result of text() like this:

span[contains(., 'testuser')]

XPath is pretty good with context. If you know exactly what text a node should have you can do:

span[.='full text in this span']

But if you want to do something like regular expressions (using exslt for example) you’ll need to use the string() function:

span[regexp:test(string(.), 'testuser')]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)