string - Getting a substring of an attribute in XPATH -


given

<foo>   <bar baz="hello, world!"> </foo> 

how last 4 characters of @baz? 1 of attempts was:

/foo/bar/@baz[substring( ., 0, -4 )] 

use:

substring(/foo/bar/@baz, string-length(/foo/bar/@baz)-3)  

do note 3 in expression.

the following wrong:

substring(/foo/bar/@baz, string-length(/foo/bar/@baz)-4)  

because returns last 5 characters of string value of baz attribute.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -