Is there a way to find a node matched on part of a value.
If I have the following:
<competition id="100" name="Barclays Premier League"/>
<competition id="101" name="CocaCola Championship" />
<competition id="102" name="CocaCola League 1" />
Given the string "Premier League" or even "Prem", how would I match the correct node and get id 100.
I have managed this using for-each and contains, but this is very inefficient and does not work fast enough for our requirements.
A double colon :: is used to separate the axis specifier from the node test. This XPath expression is a relative location path which selects all 'office' element children of the context node. Every axis has a principle node type.
Name. string-length() Function — Returns the number of characters in the string passed in as the argument to this function. If no argument is specified, the context node is converted to a string and the length of that string is returned.
String handling is not something XSLT is amazing at but there are a few options.
In this case you might try:
//competition[contains(@name,'Prem')]
see here for more options and details
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With