XSLT Similar functionality to SQL "WHERE LIKE"
Posted
by
Fishcake
on Stack Overflow
See other posts from Stack Overflow
or by Fishcake
Published on 2011-01-11T09:40:38Z
Indexed on
2011/01/11
9:53 UTC
Read the original article
Hit count: 210
xslt
I have the following XML
<Answer>
<Label>FCVCMileage</Label>
<Value>3258</Value>
<Iteration>0</Iteration>
<DataType>NUMBER</DataType>
</Answer>
And need to get the Value underneath the Mileage label. However the 4 letter prefix to Mileage could be any 1 of 8 different prefixes.
I know I could find the value by testing for every combination using xsl:if or xsl:choose but is there a more elegant way that would work similar to the following SQL and also wouldn't need changes to code being made if other prefixes were added.
WHERE label LIKE '%Mileage'
NB. There will only ever be 1 label element containing the word Mileage
Cheers!
© Stack Overflow or respective owner