Reputation: 21
I´m wondering how to use wildcards in XQuery.
I have two lines of codes which gives me the return that I want from a xml file:
for $phrase in //phrases[@pPhrase="Phrase1.mp3"]
return concat(string($phrase/@pPhrase), ", ",$phrase/ancestor::entrance/string(@name))
The problem I have is that sometimes I don´t know the exact name of the mp3 file I´m looking for.
So, if this would be a SQL query I´d type:
where pPhrase LIKE '%.mp3'
.
for $phrase in //phrases[@pPhrase LIKE ='%.mp3']
The above line doesn´t work of course, so what is the correct syntax?
Upvotes: 2
Views: 352
Reputation: 13191
You could use
//phrases[contains(@pPhrase,'.mp3']
Or to be more precise (since xPath 2.0)
//phrases[ends-with(@pPhrase,'.mp3']
Upvotes: 3