Need XPath support - with feature

I have a problem with the XPath function. I have to pull out only the entries in the XML file that their name ends with the letter "z" and I cannot get it to work. I am xmllint to manipulate the file with the cat command.

ends-with() only works on XPath 2.0, and I'm sure the server has only XPath 1.0, so I tried to enter this command:

cat //country/city[substring(@name, string-length(@name) - string-length('z') +1)]/name

but I get an error all the time, and I'm not sure if I am writing it incorrectly or if this is not the right way to do this.

+4
source share
2 answers

XPath substring(), "z". , XPath :

//country[substring(@name, string-length(@name) - string-length('z') +1) = 'z']/@name

-string-length('z') +1 0, , XPath, , @Kirill Polishchuk .

+2

:

//country[substring(@name, string-length(@name)) = 'z']
+3

Source: https://habr.com/ru/post/1628758/


All Articles